Ubuntu 》mysql -u root -p 1234时,报错 ERROR 1698 (28000): Access denied for user 'root'@'localhost'
另一篇关于清除密码、重置用户的文章:
另一篇关于清除密码、重置用户的文章:
First things first. Log in as root and stop the mysql daemon. sudo /etc/init.d/mysql stop Now lets start up the mysql daemon and skip the grant tables which store the passwords. sudo mysqld_safe --skip-grant-tables& (press Ctrl+C now to disown the process and start typing commands again) You should see mysqld start up successfully. If not, well you have bigger issues. Now you should be able to connect to mysql without a password. sudo mysql --user=root mysql update user set Password=PASSWORD('new-password'); flush privileges; exit; Now kill your running mysqld then restart it normally. sudo killall mysqld_safe& (press Ctrl+C now to disown the process and start typing commands again) /etc/init.d/mysql start You should be good to go. Try not to forget your password again. ==================================== mysql> use mysql; Database changed mysql> update user set password=password('123456') where user='root'; ERROR 1054 (42S22): Unknown column 'password' in 'field list' mysql> authentication_string字段 update user set authentication_string=password('1234') where user='root'; Query OK, 1 row affected, 1 warning (0.01 sec) Rows matched: 1 Changed: 1 Warnings: 1 |