1.在D盘将安装包解压,然后将解压的文件夹重命名成mysql
阿里云盘分享提取码:r1g2
2.在mysql创建data文件夹
3.将my.ini配置文件,复制到mysql文件夹
[client]
port=3306
default-character-set=utf8mb4
[mysql]
default-character-set=utf8mb4
[mysqld]
port=3306
# 绝对路径依据实际情况修改
basedir="D:\mysql\"
datadir="D:\mysql\data\"
# General and Slow logging.
log-output=FILE
general-log=0
general_log_file="mysql-8.0-general.log"
slow-query-log=1
slow_query_log_file="mysql-8.0-slow.log"
long_query_time=10
# Error Logging.
log-error="mysql-8.0.err"
# default_authentication_plugin=caching_sha2_password
default_authentication_plugin=mysql_native_password
default-storage-engine=INNODB
character-set-server=utf8mb4
max_connections=600
max_connect_errors=100
transaction_isolation=READ-COMMITTED
max_allowed_packet=64M
default-time-zone='+8:00'
log_timestamps=system
lower_case_table_names=1
table_open_cache=2000
tmp_table_size=512M
key_buffer_size=512M
innodb_flush_log_at_trx_commit=1
innodb_log_buffer_size=16M
innodb_buffer_pool_size=4G
innodb_log_file_size=1G
innodb_autoextend_increment=64
innodb_buffer_pool_instances=8
innodb_open_files=300
innodb_file_per_table=1
4.配置环境变量。
MYSQL_HOME:解压目录;
Path中增加:%MYSQL_HOME%\bin;
5.【cmd执行,切到bin目录执行】初始化数据库,执行命令mysqld --initialize --console,记住随机生成的密码
成功则提示Service successfully installed.
6.安装服务【cmd执行】:
mysqld install mysql8 --defaults-file="D:\mysql\my.ini"
7.启动服务【cmd执行】:
net start mysql8
sc config mysql start= auto
8.mysql –uroot –p初始化临时密码
root新密码设置为123456