溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

mysql數(shù)據(jù)庫(kù)失敗的解決方法

發(fā)布時(shí)間:2020-11-16 10:50:01 來源:億速云 閱讀:2162 作者:小新 欄目:MySQL數(shù)據(jù)庫(kù)

這篇文章將為大家詳細(xì)講解有關(guān)mysql數(shù)據(jù)庫(kù)失敗的解決方法,小編覺得挺實(shí)用的,因此分享給大家做個(gè)參考,希望大家閱讀完這篇文章后可以有所收獲。

初始化mysql數(shù)據(jù)庫(kù)失敗的解決辦法:首先找到并打開my.ini文件;然后注釋掉my.ini文件中的datadir;最后根據(jù)提示把UTF8換成UTF8MB4即可。

安裝MySQL8,安裝時(shí)初始化數(shù)據(jù)庫(kù)失敗

大概過程

  • 下載解壓到你想要安裝的目錄例如我這次是直接在C盤下。C:\mysql-8.0.17-winx64

  • 配置環(huán)境變量,把C:\mysql-8.0.17-winx64\bin加到PATH環(huán)境變量里后邊即可注意“;”號(hào)

  • 在C:\mysql-8.0.17-winx64這個(gè)目錄下新建my.ini文件。

  • 編寫my.ini文件內(nèi)容,內(nèi)容容易出錯(cuò)

  • 初始化數(shù)據(jù)庫(kù),【我就是卡到這里了】初始化成功的話或有MySQL的默認(rèn)密碼

  • 安裝數(shù)據(jù)庫(kù)

  • 啟動(dòng)登錄數(shù)據(jù)庫(kù)【第一次使用5中的默認(rèn)密碼登錄】

  • 修改密碼

mysql數(shù)據(jù)庫(kù)失敗的解決方法
在網(wǎng)上查詢到一些教程作為參考,有一個(gè)解決辦法是在一條評(píng)論里看到的,找不到原博客了,解決辦法如下圖,是把datadir那一行給注釋掉。

主要遇到的問題是,在my.ini文件的編寫上,可能會(huì)有格式、內(nèi)容上的錯(cuò)誤,在格式上要注意“\”"\""/"都要試試,還有**“C:\mysql-8.0.17-winx64”** 是否加雙引號(hào)也試下。以下是我的my.ini文件,大體內(nèi)容與參考博客相同,標(biāo)出位置是我報(bào)錯(cuò)之后修改的一些地方。

mysql數(shù)據(jù)庫(kù)失敗的解決方法
數(shù)據(jù)庫(kù)初始化時(shí)命令行出現(xiàn)的報(bào)錯(cuò)如下:

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.

mysql數(shù)據(jù)庫(kù)失敗的解決方法

問題應(yīng)該就是data文件夾的問題,那時(shí)在C:\mysql-8.0.17-winx64目錄下根本就沒有新生成的data文件夾,注釋掉my.ini文件中datadir那一行error就沒了,data文件夾也出現(xiàn)了,如下圖:
mysql數(shù)據(jù)庫(kù)失敗的解決方法
warring的解決辦法就根據(jù)其提示把UTF8換成UTF8MB4就行。改動(dòng)地方均在上圖標(biāo)注了出來。

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.

最后初始化成功,如圖:

mysql數(shù)據(jù)庫(kù)失敗的解決方法
總流程

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 服務(wù)正在啟動(dòng) .
MySQL 服務(wù)已經(jīng)啟動(dòng)成功。


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>

關(guān)于mysql數(shù)據(jù)庫(kù)失敗的解決方法就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,可以學(xué)到更多知識(shí)。如果覺得文章不錯(cuò),可以把它分享出去讓更多的人看到。

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI