【MySQL】MySQL數據庫再安裝

解決問題

  1. 安裝時提示此產品配置信息損壞,怎麼辦?
  2. 環境檢測時未響應,怎麼辦?
  3. 服務不能啓動,怎麼辦?
  4. 輸入密碼不能登陸,不使用密碼卻能登錄,是什麼原因?

涉及到的錯誤代碼:windows啓動MySQL服務1067、MySQL ERROR 1045

解決方法

電腦安裝過MySQL,想再次安裝的時候總會出些問題。一般我們會想到的就是刪除安裝目錄中的數據、刪除C盤Application Data等目錄下的數據,以及刪除註冊表中關於MySQL的數據。一番刪除之後,你會發現再次安裝的時候,會提示你:

所以說刪註冊表還是要慎重呀。

解決步驟:

  1. 找到【控制面板】 -> 【管理工具】-> 【事件查看器】->【windows日誌】

  2. 再次點擊安裝程序,等彈出配置信息損壞時,刷新【windows日誌】中的應用程序,找到錯誤信息,在【常規】選項中會提示錯誤的原因:註冊表中缺少值。
  3. 打開註冊表:【Win】+【R】打開運行窗口,輸入:regedit ,打開註冊表。
  4. 按照之前提示的路徑,刪除對應的註冊表。一定要選擇準確。
  5. 現在就可以繼續安裝了。

如果這個時候,你能一步一步安裝成功,那當然最好。但是現實可能並沒有那麼好。下面看一下我們接着會遇見的問題。

每當安裝快成功的時候,檢測環境時:到啓動服務,就一直出現未響應...

我們手動去啓動,也會提示:無法啓動 錯誤1067。

 

解決步驟:

  1. 修改安裝目錄下的my.ini文件,將default-storage-engine=INNODB改爲:
    default-storage-engine=MyISAM

  2. 啓動MySQL服務。當服務啓動成功後,發現安裝程序,第三步檢測通過,當然這並不重要,等安裝完了直接【Skip】就可以了。也許它未響應的時候,直接關掉也不影響。

    也許這個時候,你的MySQL就可以使用了。但是更可能報:ERROR 1045.

  3. 在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)
     這個時候就用密碼登陸就好了。說明我們的更改生效了。
  4. 使用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表
  5. 修改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
  6. 重啓服務:重啓服務,使用新密碼登錄。

終於安裝成功!!!

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