mysql5.7.17在windows下安裝啟動的時候提示不成功
阿新 • • 發佈:2019-02-20
在機器上首次安裝mysql,
作業系統是win7
mysql 的安裝檔案是 zip 格式的,版本是5.7.17
解壓之後,安裝步驟是
1、首先找個檔案存放這些安裝程式以及 資料
假設是E:\\mysql
2、把解壓的檔案放在E:\\mysql下,並且新建個data資料夾
3、建立環境變數mysql 路徑是E:\\mysql
新增到path 中 %MYSQL%\bin;
4、在解壓的資料夾下有個my-default.ini
的檔案,首先拷貝一份,重新命名為my.ini
修改檔案內容
只修改兩行就行
basedir = E:\\mysql datadir = E:\\mysql\\data
這兩行原先是用#號註釋掉的,
5、用系統管理員身份啟動命令列
輸入mysqld -install
這個是安裝mysql 服務的
6、輸入 mysqld --initialize
這個是因為 自動5.7.7版本之後,windows安裝mysql通過zip解壓的方式,不再包含data 資料夾,這個可以參考官網的介紹
http://dev.mysql.com/doc/refman/5.7/en/windows-initialize-data-directory.html
如果沒有data資料夾,則會在啟動mysql服務的時候起不來,觀察data資料夾下字尾名是.err的檔案就可以發現,會報這麼一些錯誤
MySQL: Table 'mysql.plugin' doesn't exist 2017-01-01T17:13:33.200113Z 0 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it. 2017-01-01T17:13:33.202113Z 0 [Note] Salting uuid generator variables, current_pid: 6908, server_start_time: 1483290810, bytes_sent: 0, 2017-01-01T17:13:33.237115Z 0 [Note] Generated uuid: '9fb87162-d045-11e6-b092-00ff173a9c42', server_start_time: 1483297718, bytes_sent: 114009376 2017-01-01T17:13:33.241115Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 9fb87162-d045-11e6-b092-00ff173a9c42. 2017-01-01T17:13:33.248116Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened. 2017-01-01T17:13:33.250116Z 0 [Warning] Failed to set up SSL because of the following SSL library error: SSL context is not usable without certificate and private key 2017-01-01T17:13:33.254116Z 0 [Note] Server hostname (bind-address): '*'; port: 3306 2017-01-01T17:13:33.259116Z 0 [Note] IPv6 is available. 2017-01-01T17:13:33.260117Z 0 [Note] - '::' resolves to '::'; 2017-01-01T17:13:33.261117Z 0 [Note] Server socket created on IP: '::'. 2017-01-01T17:13:33.266117Z 0 [Warning] Failed to open optimizer cost constant tables 2017-01-01T17:13:33.268117Z 0 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.user' doesn't exist 2017-01-01T17:13:33.270117Z 0 [ERROR] Aborting
其實這是因為這些表示放在data資料夾下的,所以我們需要先執行命令mysqld -initialize在完成mysql 的初始化,這樣的話,mysql會自動完成一些初始化的工作
7、啟動服務 net start mysql