windows10+mysql8.0.11zip安裝教程詳解
準(zhǔn)備:
MySQL8.0 Windows zip包下載地址:https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-8.0.11-winx64.zip
環(huán)境:Windows 10
一、安裝
1. 解壓zip包到安裝目錄
我的安裝目錄是D:\Program Files\mysql-8.0.11-winx64
2.配置文件
windows系統(tǒng)中配置文件默認(rèn)是安裝目錄下的 my.ini 文件,部分配置需要在初始安裝時配置,大部分也可以在安裝完成后進(jìn)行更改,不知道別人是什么情況,我的是該文件目錄下不存在my.ini文件,所以我新建了該文件,如下
寫入基本配置如下:
[mysqld] default_authentication_plugin=mysql_native_password # 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-8.0.11-winx64 datadir=D:\Program Files\mysql-8.0.11-winx64\data(這兩行是主要修改的內(nèi)容,會自動生成data文件夾,其他直接粘貼即可) port = 3306 # server_id = ..... # Remove leading # to set options mainly useful for reporting servers. # The server defaults are faster for transactions and fast SELECTs. # Adjust sizes as needed, experiment to find the optimal values. # join_buffer_size = 128M # sort_buffer_size = 2M # read_rnd_buffer_size = 2M sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES character-set-server = utf8mb4 performance_schema_max_table_instances = 600 table_definition_cache = 400 table_open_cache = 256 [mysql] default-character-set = utf8mb4 [client] default-character-set = utf8mb4
注意,里面的 basedir 是我本地的安裝目錄,datadir 是我數(shù)據(jù)庫數(shù)據(jù)文件要存放的位置,各項(xiàng)配置需要根據(jù)自己的環(huán)境進(jìn)行配置。
3.初始化數(shù)據(jù)庫
在MySQL安裝目錄的 bin 目錄下執(zhí)行命令:
mysqld --initialize --console
執(zhí)行完成后,會打印 root 用戶的初始默認(rèn)密碼,比如:
2018-05-01T14:35:01.507037Z 0 [Warning] [MY-010915] [Server] 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release. 2018-05-01T14:35:01.507640Z 0 [System] [MY-013169] [Server] D:\Program\MySQL8\bin\mysqld.exe (mysqld 8.0.11) initializing of server in progress as process 11064 2018-05-01T14:35:01.508173Z 0 [ERROR] [MY-010340] [Server] Error message file 'D:\Program Files\mysql-8.0.11-winx64\share\english\errmsg.sys' had only 1090 error messages, but it should contain at least 4512 error messages. Check that the above file is the right version for this program! 2018-05-01T14:35:05.464644Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: APWCY5ws&hjQ 2018-05-01T14:35:07.017280Z 0 [System] [MY-013170] [Server] D:\Program\MySQL8\bin\mysqld.exe (mysqld 8.0.11) initializing of server has completed
其中,第4行的“APWCY5ws&hjQ”就是初始密碼,在沒有更改密碼前,需要記住這個密碼,后續(xù)登錄需要用到。
要是你手賤,關(guān)快了,或者沒記住,那也沒事,刪掉初始化的 datadir 目錄,再執(zhí)行一遍初始化命令,又會重新生成的。當(dāng)然,也可以使用安全工具,強(qiáng)制改密碼,用什么方法,自己隨意。
4.安裝服務(wù)
在MySQL安裝目錄的 bin 目錄下執(zhí)行命令:
mysqld --install [服務(wù)名]
后面的服務(wù)名可以不寫,默認(rèn)的名字為 mysql。當(dāng)然,如果你的電腦上需要安裝多個MySQL服務(wù),就可以用不同的名字區(qū)分了,比如 mysql5 和 mysql8。
安裝完成之后,就可以通過命令net start mysql啟動MySQL的服務(wù)了。
二.更改密碼和密碼認(rèn)證插件
在MySQL安裝目錄的 bin 目錄下執(zhí)行命令:
mysql -uroot -p
這時候會提示輸入密碼,記住了第3步的密碼,填入即可登錄成功,進(jìn)入MySQL命令模式
在MySQL8.0.4以前,執(zhí)行
SET PASSWORD=PASSWORD('[修改的密碼]');
就可以更改密碼,但是MySQL8.0.4開始,這樣默認(rèn)是不行的。因?yàn)橹埃琈ySQL的密碼認(rèn)證插件是“mysql_native_password”,而現(xiàn)在使用的是“caching_sha2_password”。
因?yàn)楫?dāng)前有很多數(shù)據(jù)庫工具和鏈接包都不支持“caching_sha2_password”,為了方便,我暫時還是改回了“mysql_native_password”認(rèn)證插件。
在MySQL中執(zhí)行命令:
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';(注意一定要有分號)(注意一定要有分號)
修改密碼驗(yàn)證插件,同時修改密碼。
如果想默認(rèn)使用“mysql_native_password”插件認(rèn)證,可以在配置文件中配置default_authentication_plugin項(xiàng)。
[mysqld] default_authentication_plugin=mysql_native_password
下面看下win10下安裝mysql8.0.11
1、將下載軟件解壓在D:\mysql下。
2、在D:\mysql下創(chuàng)建my.ini,增加basedir、datadir、port等設(shè)置。
3、在系統(tǒng)環(huán)境變量中增加D:\mysql\bin
4、以管理員身份運(yùn)行cmd,初始化數(shù)據(jù)庫:mysql --initialize --console。記住初始化的root密碼。
5、安裝數(shù)據(jù)庫服務(wù):mysqld --install 服務(wù)名(缺省為mysql)
6、啟動數(shù)據(jù)庫:net start 服務(wù)名
7、登錄:mysql -u root -p,輸入初始化密碼
8、修改root密碼:alter user 'root'@'localhost' identified by 'xxxxx';
詳細(xì)信息請參考:https://dev.mysql.com/doc/refman/8.0/en
版權(quán)聲明:本站文章來源標(biāo)注為YINGSOO的內(nèi)容版權(quán)均為本站所有,歡迎引用、轉(zhuǎn)載,請保持原文完整并注明來源及原文鏈接。禁止復(fù)制或仿造本網(wǎng)站,禁止在非www.sddonglingsh.com所屬的服務(wù)器上建立鏡像,否則將依法追究法律責(zé)任。本站部分內(nèi)容來源于網(wǎng)友推薦、互聯(lián)網(wǎng)收集整理而來,僅供學(xué)習(xí)參考,不代表本站立場,如有內(nèi)容涉嫌侵權(quán),請聯(lián)系alex-e#qq.com處理。