【MySQL】MySQL資料庫再安裝
阿新 • • 發佈:2019-01-11
解決問題
- 安裝時提示此產品配置資訊損壞,怎麼辦?
- 環境檢測時未響應,怎麼辦?
- 服務不能啟動,怎麼辦?
- 輸入密碼不能登陸,不使用密碼卻能登入,是什麼原因?
涉及到的錯誤程式碼:windows啟動MySQL服務1067、MySQL ERROR 1045
解決方法
電腦安裝過MySQL,想再次安裝的時候總會出些問題。一般我們會想到的就是刪除安裝目錄中的資料、刪除C盤Application Data等目錄下的資料,以及刪除登錄檔中關於MySQL的資料。一番刪除之後,你會發現再次安裝的時候,會提示你:
所以說刪登錄檔還是要慎重呀。
解決步驟:
- 找到【控制面板】 -> 【管理工具】-> 【事件檢視器】->【windows日誌】
- 再次點選安裝程式,等彈出配置資訊損壞時,重新整理【windows日誌】中的應用程式,找到錯誤資訊,在【常規】選項中會提示錯誤的原因:登錄檔中缺少值。
- 開啟登錄檔:【Win】+【R】開啟執行視窗,輸入:regedit ,開啟登錄檔。
- 按照之前提示的路徑,刪除對應的登錄檔。一定要選擇準確。
- 現在就可以繼續安裝了。
如果這個時候,你能一步一步安裝成功,那當然最好。但是現實可能並沒有那麼好。下面看一下我們接著會遇見的問題。
每當安裝快成功的時候,檢測環境時:到啟動服務,就一直出現未響應...
我們手動去啟動,也會提示:無法啟動 錯誤1067。
解決步驟:
- 修改安裝目錄下的my.ini檔案,將default-storage-engine=INNODB改為:
default-storage-engine=MyISAM
- 啟動MySQL服務。當服務啟動成功後,發現安裝程式,第三步檢測通過,當然這並不重要,等安裝完了直接【Skip】就可以了。也許它未響應的時候,直接關掉也不影響。
也許這個時候,你的MySQL就可以使用了。但是更可能報:ERROR 1045.
- 在cmd視窗中輸入mysql -uroot -p ,不能進入資料庫。但是使用mysql、mysql -uroot卻可以進入。
這裡也可以在my.ini檔案中[mysqld]
#登入時跳過許可權檢查
skip_grant_tables
使用:mysql -uroot -p 命令進行登入,使用任意密碼都可以登入。
更改完root使用者的密碼後,應註釋掉增加的內容。
當改完密碼後使用:mysql -uroot 進行登入時,同樣會提示:
C:\Users\Administrator>mysql -uroot
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
這個時候就用密碼登陸就好了。說明我們的更改生效了。 - 使用mysql -uroot進入資料庫(注意:不要加“-p”),不要使用mysql命令直接進入。 因為他們所能看到的表不同。
C:\Users\Administrator>mysql Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 30 Server version: 5.5.62 MySQL Community Server (GPL) Copyright (c) 2000, 2018, 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; +--------------------+ | Database | +--------------------+ | information_schema | | test | +--------------------+ 2 rows in set (0.00 sec) C:\Users\Administrator>mysql -uroot Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 31 Server version: 5.5.62 MySQL Community Server (GPL) Copyright (c) 2000, 2018, 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; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | test | +--------------------+ 4 rows in set (0.00 sec)
只有mysql -uroot才能看到user表 - 修改root使用者的密碼:
mysql> use mysql Database changed mysql> UPDATE user SET password=PASSWORD('mysqladmin') WHERE user='root'; Query OK, 3 rows affected (0.00 sec) Rows matched: 3 Changed: 3 Warnings: 0 # 重新整理MySQL許可權相關的表(應該可以省略) mysql> flush privileges; Query OK, 0 rows affected (0.03 sec) mysql> select user,password From user; +------+-------------------------------------------+ | user | password | +------+-------------------------------------------+ | root | *A5C34F28328751B780896836C8A565C5C130175E | | root | *A5C34F28328751B780896836C8A565C5C130175E | | root | *A5C34F28328751B780896836C8A565C5C130175E | | | | +------+-------------------------------------------+ 4 rows in set (0.00 sec) mysql> exit Bye
- 重啟服務:重啟服務,使用新密碼登入。
終於安裝成功!!!