解決方案:虛擬機裏面安裝的mysql 數據庫
1、打開MySQL目錄下的vim /etc/my.conf文件,在文件的最後添加一行“skip-grant-tables”,保存並關閉文件。
2、 重啓服務
3、在命令行中輸入“mysql -uroot -p”(不輸入密碼),回車即可進入數據庫。
4、執行,“use mysql;”使用mysql數據庫。
5、執行,“update user set password=password(“newpassword”) where user=’root’;”(修改root的密碼)
6、重新修改目錄下的vim /etc/my.conf文件,刪除一行的“skip-grant-tables”,保存並關閉文件。
7、重啓MySQL服務。 service mysqld restart;