- 安裝包下載
1) 通過https://mirrors.huaweicloud.com/mysql/Downloads/MySQL-8.0/mysql-8.0.17-winx64.zip下載壓縮文件牍蜂;
2) 解壓到指定路徑,如:D:\mysql-8.0.17-winx64泰涂。 - 配置文件
在D:\mysql-8.0.17-winx64目錄下新建my.ini文件鲫竞,往文件寫入以下內(nèi)容:
[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. # 下邊的路徑根據(jù)自己需要自行更改
basedir = D:\mysql-8.0.17-winx64
datadir = E:\DBs\MySQL
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
- 初始化數(shù)據(jù)庫(kù)
從cmd(以管理員身份運(yùn)行)里進(jìn)入mysql解壓路徑下的bin目錄,輸入:
mysqld --initialize --console
記下打印出來第四行里隨機(jī)生成的密碼逼蒙,方便第n步里進(jìn)行密碼修改从绘。
- 安裝服務(wù)
在mysql安裝路徑下的bin路徑執(zhí)行:
mysqld --install #安裝完畢后接著輸入下行
net start mysql
- 修改密碼(可選)
還是在mysql的bin目錄下執(zhí)行,(隨機(jī)密碼有點(diǎn)難記是牢,還是改成自己容易記的僵井,以防那天忘了。妖泄。):
mysql -u root -p #接下來會(huì)提示輸入密碼驹沿,輸入之前記下的隨機(jī)密碼
# 在mysql中執(zhí)行以下命令:
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'yourNewPassword';
運(yùn)行成功后退出(exit; 或quit; 或\q;)用新密碼登錄mysql看是否修改成功。