步驟1:解壓到安裝目錄价捧,d:\software\MySQL
步驟2: 添加配置文件 d:\software\MySQL\my.ini
可參考:https://dev.mysql.com/doc/refman/8.0/en/mysqld-option-tables.html
[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:\software\MySQL
datadir = d:\software\MySQL\data
port = 3306
# server_id = .....
default_authentication_plugin=mysql_native_password
# 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
步驟3:初始化數(shù)據(jù)庫(kù)
-- 注意:執(zhí)行日志會(huì)生成root賬戶的初始密碼
d:\software\MySQL\bin\mysqld --initialize --console
步驟4:安裝服務(wù)
d:\software\MySQL\bin\mysqld --install MySQL8
步驟5:?jiǎn)?dòng)服務(wù)
net start MySQL8
net stop MySQL8
步驟6:修改root密碼
mysql -uroot -p $password -- 步驟4生成的臨時(shí)密碼
-- 注意配置選項(xiàng)【my.ini】
-- [mysqld]
-- 設(shè)置默認(rèn)使用mysql_native_password插件認(rèn)證
-- default_authentication_plugin=mysql_native_password
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';