這篇文章將為大家詳細講解有關mysql數據庫失敗的解決方法,小編覺得挺實用的,因此分享給大家做個參考,希望大家閱讀完這篇文章后可以有所收獲。
初始化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 服務已經啟動成功。 C:\mysql-8.0.17-winx64\bin>mysql -u root -p Enter password: ************ Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 8 Server version: 8.0.17 Copyright (c) 2000, 2019, 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> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '111111'; Query OK, 0 rows affected (0.01 sec) mysql>
關于mysql數據庫失敗的解決方法就分享到這里了,希望以上內容可以對大家有一定的幫助,可以學到更多知識。如果覺得文章不錯,可以把它分享出去讓更多的人看到。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。