MySQL: Error 1045 (28000): Access denied for user ‘root’@'localhost’ (using password: NO)

来源:互联网 发布:高中编程软件 编辑:程序博客网 时间:2024/06/05 03:08

原地址:http://myotragusbalearicus.wordpress.com/2011/11/21/mysql-error-1045-28000-access-denied-for-user-rootlocalhost-using-password-no/

I’ve upgraded MySQL server version to 5.1.54-1ubuntu4 and when I try to connect to the database I’m getting this error:


$ mysql -u root Error 1045 (28000): Access deniedfor user 'root'@'localhost'(using password: NO)


Maybe updating the package the updater overwrote the root password.

To restore it:

  • Stop mysqld deamons.
$sudo service mysql stop


  • Go  to  mysql/bin directory
$cd /usr/bin

  • Start a mysql deamon with this option:
$sudo mysqld_safe --skip-grant-tables

  • Open another terminal and open a mysql session to execute this:
$ mysqlmysql> use mysql;mysql> UPDATE user SET password=PASSWORD('YOUR_NEW_PASSWORD_HERE') WHERE user ='root';mysql> exit;

  • Now kill the mysqld_safe process and restart mysqld normally:
$sudo service mysql start


原创粉丝点击