解决MySql登陆报错ERROR 1045 (28000)问题(针对Mac解决方案)

问题描述

Mac搭建php开发环境:Apache+php+MySql时,登陆Mysql报错。
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

解决方案

1. 停止Mysql服务。(Mac在系统偏好里停止Mysql)

2. 以命令行参数启动mysql。在终端输入命令:
sudo /usr/local/mysql/bin/mysqld_safe --skip-grant-tables

3. 重置密码123456。在终端输入命令:

mysql -u root
UPDATE mysql.user SET authentication_string=PASSWORD('123456') WHERE User='root';
FLUSH PRIVILEGES;
\q

4. 输入完成后使用 contrl+z 键结束输入。

5. MySql实现密码登陆,在终端输入命令:
mysql -uroot -p123456

 

 

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注