My.ini設(shè)置成UTF-8第一行報(bào)錯(cuò)?
Windows 上安裝 MySQL
Windows 上安裝 MySQL 相對(duì)來說會(huì)較為簡單鼎姐,點(diǎn)擊鏈接https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-8.0.11-winx64.zip下載 zip 包求晶。
最新版本可以在MySQL 下載中下載中查看窝稿。
下載完后父能,我們將 zip 包解壓到相應(yīng)的目錄,這里我將解壓后的文件夾放在CC:\web\mysql-8.0.17-winx64下罕模。
接下來我們需要配置下 MySQL 的配置文件
打開剛剛解壓的文件夾C:\web\mysql-8.0.17-winx64?榴捡,在該文件夾下創(chuàng)建my.ini配置文件匹中,編輯my.ini配置以下基本信息:
[mysqld]
# 設(shè)置3306端口
port=3306
# 設(shè)置mysql的安裝目錄
basedir=C:\\web\\mysql-8.0.17-winx64
#切記此處一定要用雙斜杠\\夏漱,單斜杠我這里會(huì)出錯(cuò),不過看別人的教程顶捷,有的是單斜杠挂绰。自己嘗試吧
# 設(shè)置mysql數(shù)據(jù)庫的數(shù)據(jù)的存放目錄
datadir=C:\\web\\mysql-8.0.17-winx64\\data? ? #我不知道這里要不要設(shè)置,一開始的問題我以為是這里
# 允許最大連接數(shù)
max_connections=200
# 允許連接失敗的次數(shù)服赎。這是為了防止有人從該主機(jī)試圖攻擊數(shù)據(jù)庫系統(tǒng)
max_connect_errors=10
# 服務(wù)端使用的字符集默認(rèn)為UTF8
character-set-server=utf8
# 創(chuàng)建新表時(shí)將使用的默認(rèn)存儲(chǔ)引擎
default-storage-engine=INNODB
# 默認(rèn)使用“mysql_native_password”插件認(rèn)證
default_authentication_plugin=mysql_native_password
[mysql]
# 設(shè)置mysql客戶端默認(rèn)字符集
default-character-set=utf8
[client]
# 設(shè)置mysql客戶端連接服務(wù)端時(shí)默認(rèn)使用的端口
port=3306
default-character-set=utf8
然后開始網(wǎng)上所說的命令:
C:\Users\Administrator>cd ?C:\web\mysql-8.0.17-winx64
C:\web\mysql-8.0.17-winx64>cd bin
C:\web\mysql-8.0.17-winx64\bin>mysqld --initialize --console
2019-08-22T11:10:04.129559Z 0 [System] [MY-013169] [Server] C:\web\mysql-8.0.17-
winx64\bin\mysqld.exe (mysqld 8.0.17) initializing of server in progress as proc
ess 4324
2019-08-22T11:10:04.133559Z 0 [Warning] [MY-013242] [Server] --character-set-ser
ver: 'utf8' is currently an alias for the character set UTF8MB3, but will be an
alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to
be unambiguous.
2019-08-22T11:10:32.075157Z 5 [Note] [MY-010454] [Server] A temporary password i
s generated for root@localhost: sSw#mgSap3>j
2019-08-22T11:10:43.377804Z 0 [System] [MY-013170] [Server] C:\web\mysql-8.0.17-
winx64\bin\mysqld.exe (mysqld 8.0.17) initializing of server has completed
C:\web\mysql-8.0.17-winx64\bin>mysqld install
The service already exists!
The current server installed: C:\web\mysql-8.0.17-winx64\bin\mysqld MySQL
C:\web\mysql-8.0.17-winx64\bin>net start mysql
服務(wù)沒有響應(yīng)控制功能葵蒂。
請(qǐng)鍵入 NET HELPMSG 2186 以獲得更多的幫助。
###############################
出現(xiàn)這個(gè)問題很無語重虑,以為安裝錯(cuò)了或者目錄設(shè)置錯(cuò)了践付,或者my.ini少了\\,或者初始化錯(cuò)了嚎尤,最后搞了一下午荔仁,發(fā)現(xiàn)直接輸入
mysqld --console服務(wù)端就開好了:
C:\web\mysql-8.0.17-winx64\bin>mysqld --console
2019-08-22T11:13:12.118311Z 0 [System] [MY-010116] [Server] C:\web\mysql-8.0.17-
winx64\bin\mysqld.exe (mysqld 8.0.17) starting as process 4200
2019-08-22T11:13:12.125312Z 0 [Warning] [MY-013242] [Server] --character-set-ser
ver: 'utf8' is currently an alias for the character set UTF8MB3, but will be an
alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to
be unambiguous.
2019-08-22T11:13:16.860582Z 0 [Warning] [MY-010068] [Server] CA certificate ca.p
em is self signed.
2019-08-22T11:13:17.482618Z 0 [System] [MY-010931] [Server] C:\web\mysql-8.0.17-
winx64\bin\mysqld.exe: ready for connections. Version: '8.0.17' ?socket: '' ?por
t: 3306 ?MySQL Community Server - GPL.
2019-08-22T11:13:17.571623Z 0 [System] [MY-011323] [Server] X Plugin ready for c
onnections. Bind-address: '::' port: 33060
接著客戶端就可以連接了: