Access denied for ** 報錯解決辦法

方法一: 在 root 用戶下:
# /etc/init.d/mysql stop
# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
# mysql -u root mysql
mysql> UPDATE user SET Password=PASSWORD('newpassword') where USER='root';
mysql> FLUSH PRIVILEGES;
mysql> quit

# /etc/init.d/mysql restart
# mysql -uroot -p
Enter password: <輸入新設的密碼newpassword>
完成。

 

以下部分是別人的相關信息整理:懶得自己整理,就直接粘過來了:

錯誤信息。
解釋:YES,說明密碼沒有問題。可能是限制不讓在本地登陸。於是實用
添加 -h 61.139.xx.252繞過本地測試,也未成功
[root@fms1 ok]# mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
[root@fms1 ok]# mysql -h 61.139.xx.252 -u root -p
Enter password:
ERROR 1130 (00000): Host '61.139.76.252' is not allowed to connect to this MySQL server
註釋: 1130報錯信息說明不允許遠程訪問。沒有給該用戶授權
然後重新修改密碼後可以正常訪問:
 
[root@fms1 ok]# /etc/init.d/mysql stop
Shutting down MySQL.[確定]
[root@fms1 ok]# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
[1] 6699
[root@fms1 ok]# mysql -u root mysql
.......
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| test               |
+--------------------+
3 rows in set (0.00 sec)
mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> show tables;
+---------------------------+
| Tables_in_mysql           |
+---------------------------+
.............................
.............................
.............................
| user                      |
+---------------------------+
17 rows in set (0.00 sec)
mysql> UPDATE user SET Password=PASSWORD('newpassword') 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@fms1 ok]# killall -9 mysqld
[root@fms1 ok]# /etc/init.d/mysql start
Starting MySQL[確定]
[root@fms1 ok]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or /g.
Your MySQL connection id is 3
Server version: 5.0.45-community MySQL Community Edition (GPL)
Type 'help;' or '/h' for help. Type '/c' to clear the buffer.
mysql> GRANT ALL PRIVILEGES ON *.* TO root@'%' IDENTIFIED BY "newpasswd";  #用於給用戶授權。
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> update user set user="newname" where user="root"; #改名
Query OK, 4 rows affected (0.00 sec)
Rows matched: 4  Changed: 4  Warnings: 0
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> quit
Bye
支持完成了修改密碼,授權,改名的工作。
[root@fms1 ok]# mysql -u centos -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or /g.
Your MySQL connection id is 4
Server version: 5.0.45-community MySQL Community Edition (GPL)
Type 'help;' or '/h' for help. Type '/c' to clear the buffer.
mysql> show databases;
錯誤信息沒有了。
 
總結:
錯誤提示:
# mysql -uroot -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
解決方法:1

方法一:
# /etc/init.d/mysql stop
# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
# mysql -u root mysql
mysql> UPDATE user SET Password=PASSWORD('newpassword') where USER='root';
mysql> FLUSH PRIVILEGES;
mysql> quit

# /etc/init.d/mysql restart
# mysql -uroot -p
Enter password: <輸入新設的密碼newpassword>
完成。
 ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES )
 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章