C:\Users\電腦ID>D:
D:\> cd D:\wamp\wamp64\bin\mysql\mysql5.7.19\bin
D:\wamp\wamp64\bin\mysql\mysql5.7.19\bin>mysql -hlocalhost -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 5.7.19 MySQL Community Server (GPL)
Copyright (c) 2000, 2017, 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> show databases;
如果報錯
“Access denied for user 'root'@'localhost' (using password:YES)”
應該做下面處理:
解決方案:
1、打開MySQL目錄下的my.ini文件,在文件的最后添加一行“skip-grant-tables”,保存並關閉文件。
2、重啟MySQL服務。
3、在命令行中輸入“mysql -uroot -p”(不輸入密碼),回車即可進入數據庫。
4、執行,“use mysql;”使用mysql數據庫。
5、執行,“update user set password=PASSWORD("rootadmin") where user='root';”(修改root的密碼)
(期間我還select下user表中的記錄,查詢全部的時候顯示了一些亂碼,然后我只查詢了user表中的Host、User、Password字段,貌似當時顯示了3條記錄,有1個沒有名稱。當然,為了解決問題,這些我也管不了了。)
6、打開MySQL目錄下的my.ini文件,刪除最后一行的“skip-grant-tables”,保存並關閉文件。
7、重啟MySQL服務。
8、在命令行中輸入“mysql -uroot -prootadmin”,問題搞定!