ERROR 1045 (28000): Access denied for user 'root'@'localhost'(using password: NO)

登陆mysql出现如下错误

[root@NeoKylin-CNVL/]# mysql

ERROR 1045 (28000): Access denied for user 'root'@'localhost'(using password: NO)

 

解决办法:

[root@NeoKylin-CNVL/]# /etc/init.d/mysql stop

[root@NeoKylin-CNVL/]#mysqld_safe --user=mysql --skip-grant-tables--skip-networking &

[2] 8196

[root@NeoKylin-CNVL/]# 160114 19:30:36 mysqld_safe Logging to

'/var/lib/mysql/NeoKylin-CNVL.cs1cloud.internal.err'.

16011419:30:36 mysqld_safe A mysqld process already exists

 

mysql -u root mysql

Readingtable information for completion of table and column names

You canturn off this feature to get a quicker startup with -A

Welcometo the MySQL monitor.  Commands end with; or \g.

YourMySQL connection id is 2

Serverversion: 5.6.25 MySQL Community Server (GPL)

Copyright(c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.

Oracleis a registered trademark of Oracle Corporation and/or its

affiliates.Other names may be trademarks of their respective

owners.

Type'help;' or '\h' for help. Type '\c' to clear the current input statement.

 

mysql> UPDATE user SETPassword=PASSWORD('123') where USER='root';

QueryOK, 4 rows affected (0.00 sec)

Rowsmatched: 4  Changed: 4  Warnings: 0

 

mysql> FLUSH PRIVILEGES;

QueryOK, 0 rows affected (0.00 sec)

 

mysql> quit

重新启动mysql

[root@NeoKylin-CNVL/]# /etc/init.d/mysqld restart

[root@NeoKylin-CNVL/]#mysql -uroot -p

Enterpassword:

 

登陆成功

mysql>


本文出自 “DOSOM” 博客,谢绝转载!

你可能感兴趣的:(error,1045,28000)