MYsql錯誤程式碼 1045 解決方案
阿新 • • 發佈:2019-01-04
Access denied for user 'root'@'localhost' (using password:YES)
一、Windows平臺下mysql 1054錯誤:
進入dos命令列,切換到你的MySQL bin目錄下
比如我的是 D:\Program Files\MySQL\MySQL Server 5.0\bin --(注意自己的my.ini位置)
C:\Users\Administrator>d:
D:\>cd Program Files\MySQL\MySQL Server 5.0\bin
D:\Program Files\MySQL\MySQL Server 5.0\bin>
D:\Program Files\MySQL\MySQL Server 5.0\bin>mysqld-nt --defaults-file="D:\Program Files\MySQL\MySQL Server 5.0\my.ini" --console --skip-grant-tables
140116 10:55:29 InnoDB: Started; log sequence number 0 289705428
140116 10:55:29 [Note] mysqld-nt: ready for connections.
Version: '5.0.96-community-nt' socket: '' port: 3306 MySQL Community Edition (GPL)
看到紅色字型一行就說明MySQL已經起來了。
另外再開一個DOS視窗,同樣切到mysql bin目錄下
D:\Program Files\MySQL\MySQL Server 5.0\bin>mysql -uroot mysqlWelcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.0.96-community-nt MySQL Community Server (GPL)
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql>
mysql> UPDATE user SET Password=PASSWORD(’newpassword’) where USER=’root’;
mysql> FLUSH PRIVILEGES;
mysql> quit
然後關閉mysql服務
之後正常重啟MySQL服務就行了。
D:\Program Files\MySQL\MySQL Server 5.0\bin>net start mysql
MySQL 服務正在啟動 .
MySQL 服務已經啟動成功。
D:\Program Files\MySQL\MySQL Server 5.0\bin>mysql -uroot -p
Enter password: ********* --<這裡輸入剛剛重置的新密碼>
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.0.96-community-nt MySQL Community Edition (GPL)
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>
二、在Linux平臺中Mysql訪問是,提示1054錯誤
# /etc/init.d/mysqld stop
# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
# mysql -uroot mysql
mysql> UPDATE user SET Password=PASSWORD(’newpassword’) where USER=’root’;
mysql> FLUSH PRIVILEGES;
mysql> quit
# /etc/init.d/mysqld restart
# mysql -uroot -p
Enter password: <輸入新設的密碼newpassword>
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 28
Server version: 5.1.73-community MySQL Community Server (GPL)
Copyright (c) 2000, 2013, 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>