1. 程式人生 > >安裝mysql報錯5.7.13-Table 'mysql.user' doesn't existFor more information

安裝mysql報錯5.7.13-Table 'mysql.user' doesn't existFor more information

臨時寫的一個小系統客戶要求用mysql,所以下載一個來研究下。
解壓後開始配置my.ini

配置my.ini


[mysql]
# 設定mysql客戶端預設字符集
default-character-set=utf8
[mysqld]
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
# These are commonly set, remove the # and set as required.
basedir=D:\Program Files\mysql-5.7.13
datadir=D:\Program Files\mysql-5.7.13\data
tmpdir=D:\Program Files\mysql-5.7.13\data
port=3306
server_id=1234
# 允許最大連線數
max_connections=200
# 服務端使用的字符集預設為8位元編碼的latin1字符集
character-set-server=utf8
# 建立新表時將使用的預設儲存引擎
default-storage-engine=INNODB
sql-mode=NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
explicit_defaults_for_timestamp=true

安裝服務

用管理員身份開啟cmd.exe,進到mysql的bin目錄


D:\Program Files\mysql-5.7.13\bin>mysqld install
Service successfully installed.
D:\Program Files\mysql-5.7.13\bin>net start mysql
MySQL 服務正在啟動 .
MySQL 服務無法啟動。
服務沒有報告任何錯誤。
請鍵入 NET HELPMSG 3534 以獲得更多的幫助。

報錯了,開啟系統日誌提示:
Fatal error: Can’t open and lock privilege tables: Table ‘mysql.user’ doesn’t existFor more information, see Help and Support Center at

原來新版的mysql需要啟動服務前先執行初始化,如下:

D:\Program Files\mysql-5.7.13\bin>mysqld --initialize
D:\Program Files\mysql-5.7.13\bin>net start mysql
MySQL 服務正在啟動 .
MySQL 服務已經啟動成功。

好了,我要開始切換到mysql資料庫了。