Last active
December 19, 2015 15:19
-
-
Save wgm89/5975417 to your computer and use it in GitHub Desktop.
fix mysql how to fix Access denied for user 'root'@'localhost'
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| php 可以连接 mysql , 但 cli 下 不能使用密码登录 ,空密码可登录,应该是权限在作怪. | |
| skip-grant-tables下 不能 分配mysql 用户权限 . | |
| 只能这样 : mysql_query(GRANT ALL ON mydb.* TO 'someuser'@'somehost';); | |
| 通常以下就可解决: | |
| Follow steps below | |
| 1.Start the mysql server instance or daemon with the --skip-grant-tables option. (security setting) | |
| $ mysqld --skip-grant-tables | |
| 2.Then Execute these statements. | |
| $ mysql -u root mysql | |
| $mysql> UPDATE user SET Password=PASSWORD('my_password') where USER='root'; | |
| $mysql> FLUSH PRIVILEGES; | |
| 3.Finally, restart the instance/daemon without the --skip-grant-tables option. | |
| $ /etc/init.d/mysql restart | |
| 4.You should be able to connect with your new password. | |
| $ mysql -u root -p | |
| Enter password: my_password |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment