Centos 安裝mysql5.6後連接報錯:ERROR 1045 (28000)

在CentOS 6.5中,安裝mysql 5.6版本後,啓動Mysql服務,使用命令:

mysql -u root -p pouyye 

連接時報錯:

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

解決方法:
1.停止mysqld服務
2.使用如下命令啓動服務:

mysqld_safe --user=mysql --skip-grant-tables

注:

–skip-grant-tables:表示跳過授權控制
3.啓動後效果如下:

150922 11:33:57 mysqld_safe Logging to '/var/log/mysqld.log'.
150922 11:33:57 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql

4.另開一shell窗口,使用命令:

mysql

連接到mysql數據庫,然後分別執行如下操作:

mysql> select host,user from user where user ='root';
+-------------+------+
| host        | user |
+-------------+------+
| %           | root |
| 127.0.0.1   | root |
| VM000001964 | root |
+-------------+------+
3 rows in set (0.00 sec)

mysql> update user set password=password('Chinawiservqz#') 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

5.重啓mysqld服務:

service mysqld restart

6.最後執行命令,升級mysql數據庫結構。

mysql_upgrade -uroot -p
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章