初始化mysql資料庫失敗的解決方法:先找到並開啟my.ini檔案;然後註解掉my.ini檔案中的datadir;最後根據提示把UTF8換成UTF8MB4即可。
推薦:《mysql影片教學》
安裝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那一行初始化mysql的資料庫失敗怎麼辦就沒了,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的資料庫失敗怎麼辦的詳細內容。更多資訊請關注PHP中文網其他相關文章!

掌握添加MySQL用戶的方法對於數據庫管理員和開發者至關重要,因為它確保數據庫的安全性和訪問控制。 1)使用CREATEUSER命令創建新用戶,2)通過GRANT命令分配權限,3)使用FLUSHPRIVILEGES確保權限生效,4)定期審計和清理用戶賬戶以維護性能和安全。

chosecharforfixed-lengthdata,varcharforvariable-lengthdata,andtextforlargetextfield.1)chariseffity forconsistent-lengthdatalikecodes.2)varcharsuitsvariable-lengthdatalikenames,ballancingflexibilitibility andperformance.3)

在MySQL中處理字符串數據類型和索引的最佳實踐包括:1)選擇合適的字符串類型,如CHAR用於固定長度,VARCHAR用於可變長度,TEXT用於大文本;2)謹慎索引,避免過度索引,針對常用查詢創建索引;3)使用前綴索引和全文索引優化長字符串搜索;4)定期監控和優化索引,保持索引小巧高效。通過這些方法,可以在讀取和寫入性能之間取得平衡,提升數據庫效率。

ToaddauserremotelytoMySQL,followthesesteps:1)ConnecttoMySQLasroot,2)Createanewuserwithremoteaccess,3)Grantnecessaryprivileges,and4)Flushprivileges.BecautiousofsecurityrisksbylimitingprivilegesandaccesstospecificIPs,ensuringstrongpasswords,andmonitori

tostorestringsefliceflicyInmySql,ChooSetherightDataTypeBasedyOrneOrneEds:1)USEcharforFixed-LengthStstringStringStringSlikeCountryCodes.2)UseVarcharforvariable-lengtthslikenames.3)USETEXTCONTENT.3)

選擇MySQL的BLOB和TEXT數據類型時,BLOB適合存儲二進制數據,TEXT適合存儲文本數據。 1)BLOB適用於圖片、音頻等二進制數據,2)TEXT適用於文章、評論等文本數據,選擇時需考慮數據性質和性能優化。

No,youshouldnotusetherootuserinMySQLforyourproduct.Instead,createspecificuserswithlimitedprivilegestoenhancesecurityandperformance:1)Createanewuserwithastrongpassword,2)Grantonlynecessarypermissionstothisuser,3)Regularlyreviewandupdateuserpermissions

mySqlStringDatatAtatPessHouldBechoseBasedondatActarActeristicsAndusecases:1)USEcharforFixed lengthStstringStringStringSlikeCountryCodes.2)usevarcharforvariable-lengtthslikeLikenames.3)usebarnionororvarinyorvarinyorvarybinarydatalgebenedaTalgeextocrabextrapon.4)


熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

Video Face Swap
使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

Safe Exam Browser
Safe Exam Browser是一個安全的瀏覽器環境,安全地進行線上考試。該軟體將任何電腦變成一個安全的工作站。它控制對任何實用工具的訪問,並防止學生使用未經授權的資源。

Atom編輯器mac版下載
最受歡迎的的開源編輯器

SublimeText3漢化版
中文版,非常好用

WebStorm Mac版
好用的JavaScript開發工具

Dreamweaver Mac版
視覺化網頁開發工具