【QA5】【mysql问题】ERROR 1045 (28000): Access denied for...

问题现象:

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

原因分析:由于密码错误等原因导致连接失败。

解决办法:修改用户名对应密码

root@hao-ubuntu:/usr/local/autotest# /etc/init.d/mysql stop
root@hao-ubuntu:/usr/local/autotest# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
[1] 1828
root@hao-ubuntu:/usr/local/autotest# 120502 13:59:51 mysqld_safe Logging to syslog.
120502 13:59:52 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
mysql -uroot mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.1.62-0ubuntu0.11.04.1 (Ubuntu)

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

Oracle is 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 set password=PASSWORD('root') where USER='root';
Query OK, 3 rows affected (0.00 sec)
Rows matched: 3  Changed: 3  Warnings: 0

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

mysql> quit
Bye
root@hao-ubuntu:/usr/local/autotest# /etc/init.d/mysql restart
Rather than invoking init scripts through /etc/init.d, use the service(8)
utility, e.g. service mysql restart

Since the script you are attempting to invoke has been converted to an
Upstart job, you may also use the stop(8) and then start(8) utilities,
e.g. stop mysql ; start mysql. The restart(8) utility is also available.
mysql start/running, process 1979
root@hao-ubuntu:/usr/local/autotest# mysql -uroot -proot
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 35
Server version: 5.1.62-0ubuntu0.11.04.1 (Ubuntu)

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

Oracle is 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>

你可能感兴趣的:(Access)