在機(jī)器上首次安裝MySQL,
操作系統(tǒng)是win7
mysql 的安裝文件是 zip 格式的,版本是5.7.17
解壓之后,安裝步驟是
1、首先找個(gè)文件存放這些安裝程序以及 數(shù)據(jù)
假設(shè)是E://mysql
2、把解壓的文件放在E://mysql下,并且新建個(gè)data文件夾
3、創(chuàng)建環(huán)境變量mysql 路徑是E://mysql
添加到path 中 %MYSQL%/bin;
4、在解壓的文件夾下有個(gè)my-default.ini
的文件,首先拷貝一份,重命名為my.ini
修改文件內(nèi)容
只修改兩行就行
| basedir = E://mysql datadir = E://mysql//data | 
這兩行原先是用#號(hào)注釋掉的,
5、用系統(tǒng)管理員身份啟動(dòng)命令行
輸入mysqld  -install
這個(gè)是安裝mysql 服務(wù)的
6、輸入 mysqld --initialize
這個(gè)是因?yàn)?自動(dòng)5.7.7版本之后,windows安裝mysql通過(guò)zip解壓的方式,不再包含data 文件夾,這個(gè)可以參考官網(wǎng)的介紹
http://dev.mysql.com/doc/refman/5.7/en/windows-initialize-data-directory.html
如果沒(méi)有data文件夾,則會(huì)在啟動(dòng)mysql服務(wù)的時(shí)候起不來(lái),觀察data文件夾下后綴名是.err的文件就可以發(fā)現(xiàn),會(huì)報(bào)這么一些錯(cuò)誤
| 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 | 
其實(shí)這是因?yàn)檫@些表示放在data文件夾下的,所以我們需要先執(zhí)行命令mysqld -initialize在完成mysql 的初始化,這樣的話,mysql會(huì)自動(dòng)完成一些初始化的工作            
新聞熱點(diǎn)
疑難解答
圖片精選