共計 2895 個字符,預計需要花費 8 分鐘才能閱讀完成。
自動寫代碼機器人,免費開通
這篇文章將為大家詳細講解有關 mysql 數據庫失敗的解決方法,丸趣 TV 小編覺得挺實用的,因此分享給大家做個參考,希望大家閱讀完這篇文章后可以有所收獲。
初始化 mysql 數據庫失敗的解決辦法:首先找到并打開 my.ini 文件;然后注釋掉 my.ini 文件中的 datadir;最后根據提示把 UTF8 換成 UTF8MB4 即可。
安裝 MySQL8,安裝時初始化數據庫失敗
大概過程
下載解壓到你想要安裝的目錄例如我這次是直接在 C 盤下。C:\mysql-8.0.17-winx64
配置環境變量,把 C:\mysql-8.0.17-winx64\bin 加到 PATH 環境變量里后邊即可注意“;”號
在 C:\mysql-8.0.17-winx64 這個目錄下新建 my.ini 文件。
編寫 my.ini 文件內容,內容容易出錯
初始化數據庫,【我就是卡到這里了】初始化成功的話或有 MySQL 的默認密碼
安裝數據庫
啟動登錄數據庫【第一次使用 5 中的默認密碼登錄】
修改密碼
在網上查詢到一些教程作為參考,有一個解決辦法是在一條評論里看到的,找不到原博客了,解決辦法如下圖,是把 datadir 那一行給注釋掉。
主要遇到的問題是,在 my.ini 文件的編寫上,可能會有格式、內容上的錯誤,在格式上要注意“\”\ / 都要試試,還有 **“C:\mysql-8.0.17-winx64”** 是否加雙引號也試下。以下是我的 my.ini 文件,大體內容與參考博客相同,標出位置是我報錯之后修改的一些地方。
數據庫初始化時命令行出現的報錯如下:
C:\mysql-8.0.17-winx64\bin mysqld --initialize --console
2019-08-24T13:33:22.622321Z 0 [System] [MY-013169] [Server] C:\mysql-8.0.17-winx64\bin\mysqld.exe (mysqld 8.0.17) initializing of server in progress as process 8404
2019-08-24T13:33:22.624188Z 0 [Warning] [MY-013243] [Server] --character-set-server: The character set UTF8MB3 is deprecated and will be removed in a future release. Please consider using UTF8MB4 instead.
2019-08-24T13:33:22.625619Z 0 [ERROR] [MY-010457] [Server] --initialize specified but the data directory has files in it. Aborting.
2019-08-24T13:33:22.625635Z 0 [ERROR] [MY-013236] [Server] The designated data directory C:\mysql-8.0.17-winx64\data\ is unusable. You can remove all files that the server added to it.
2019-08-24T13:33:22.643590Z 0 [ERROR] [MY-010119] [Server] Aborting
2019-08-24T13:33:22.643744Z 0 [System] [MY-010910] [Server] C:\mysql-8.0.17-winx64\bin\mysqld.exe: Shutdown complete (mysqld 8.0.17) MySQL Community Server - GPL.
問題應該就是 data 文件夾的問題,那時在 C:\mysql-8.0.17-winx64 目錄下根本就沒有新生成的 data 文件夾,注釋掉 my.ini 文件中 datadir 那一行 error 就沒了,data 文件夾也出現了,如下圖:
warring 的解決辦法就根據其提示把 UTF8 換成 UTF8MB4 就行。改動地方均在上圖標注了出來。
2019-08-24T13:33:22.624188Z 0 [Warning] [MY-013243] [Server] --character-set-server: The character set UTF8 is deprecated and will be removed in a future release. Please consider using UTF8MB4 instead.
最后初始化成功,如圖:
總流程
C:\mysql-8.0.17-winx64\bin mysqld --initialize --console
2019-08-24T13:37:11.590803Z 0 [System] [MY-013169] [Server] C:\mysql-8.0.17-winx64\bin\mysqld.exe (mysqld 8.0.17) initializing of server in progress as process 2484
2019-08-24T13:37:15.862830Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: 37swG%65Qjf1
2019-08-24T13:37:17.783854Z 0 [System] [MY-013170] [Server] C:\mysql-8.0.17-winx64\bin\mysqld.exe (mysqld 8.0.17) initializing of server has completed
C:\mysql-8.0.17-winx64\bin mysqld --install
The service already exists!
The current server installed: C:\mysql-8.0.17-winx64\bin\mysqld.exe MySQL
C:\mysql-8.0.17-winx64\bin net start mysql
MySQL 服務正在啟動 .
MySQL 服務已經啟動成功。
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 ALTER USER root @ localhost IDENTIFIED WITH mysql_native_password BY 111111
Query OK, 0 rows affected (0.01 sec)
mysql
關于 mysql 數據庫失敗的解決方法就分享到這里了,希望以上內容可以對大家有一定的幫助,可以學到更多知識。如果覺得文章不錯,可以把它分享出去讓更多的人看到。
向 AI 問一下細節
丸趣 TV 網 – 提供最優質的資源集合!