在mac下安装mysql时 Access denied for user 'root'@'localhost' (using password: YES) 如何解决

1.配置mysql的环境变量
cd ~
vim .bash_profile
加入 export PATH=${PATH}:/usr/local/mysql/bin

2.关闭服务器
sudo /usr/local/mysql/support-files/mysql.server stop
如果遇到pid找不到可在系统偏好设置里手动关闭mysql

3.sudo mysqld_safe –skip-grant-tables

4.打开另一个终端
输入mysql
mysql> select User from mysql.user;
set global read_only=0;
flush privileges;
CREATE USER ‘用户名’@’localhost’ IDENTIFIED BY “密码”;
grant all privileges on . to 用户名@’localhost’;
quit
5.打开Navicat尝试建立一个连接,利用刚刚创建的用户名和密码

你可能感兴趣的:(java-EE)