Windows安装多版本MySQL

5.7 - 配置
my.ini

[client]
port = 3307

[mysql]
default-character-set = utf8mb4

[mysqld]
port = 3307
server_id = 1
character-set-server = utf8mb4

basedir = "E://MySQL/mysql5.7"
datadir = "E://MySQL/mysql5.7/data"

# 将所有表名转换为小写字母
lower_case_table_names=1

# 每个表都使用独立表空间文件
innodb_file_per_table = 1

# 使用系统时间戳记录日志
log_timestamps=SYSTEM

log_syslog = 0

# 记录错误日志到error.log文件
log-error = E://MySQL/mysql5.7/logs/error.log

# 开启慢查询日志
slow_query_log = 1

# 慢查询日志文件名为slow.log
slow_query_log_file = E://MySQL/mysql5.7/logs/slow.log

# 慢查询阈值为3秒
long_query_time = 2

# 允许最大连接数为200
max_connections=200

default-storage-engine=INNODB
# sql_mode=NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
sql_mode=ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER

skip-grant-tables

8.0 配置
my.ini

[client]
port = 3308

[mysql]
default-character-set = utf8mb4

[mysqld]
port = 3308
server_id = 2
character-set-server = utf8mb4
basedir = "E://MySQL/mysql8.0"
datadir = "E://MySQL/mysql8.0/data"

default_authentication_plugin=mysql_native_password

log_bin = "E://MySQL/mysql8.0/logs/mysql-bin.log"
log_error = "E://MySQL/mysql8.0/logs/error.log"

general_log = ON
general_log_file = "E://MySQL/mysql8.0/logs/mysql.log"

slow_query_log = ON
slow_query_log_file = "E://MySQL/mysql8.0/logs/mysql-slow.log"
long_query_time = 2

max_connections=200
default-storage-engine=INNODB

sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION


#skip-grant-tables  -8.0不能用这个, 会报错

超管终端

#初始化
mysqld --defaults-file="E://MySQL/mysql5.7/my.ini" --initialize --console
#服务
mysqld --install "MySQL57" --defaults-file="E://MySQL/mysql5.7/my.ini"

#初始化
mysqld --defaults-file="E://MySQL/mysql8.0/my.ini" --initialize --console
#服务
mysqld --install "MySQL80" --defaults-file="E://MySQL/mysql8.0/my.ini"

待测试超管终端

#初始化
mysqld --defaults-file="E://MySQL/mysql5.7/my.ini" --initialize-insecure --user=mysql --console
#服务
mysqld --install "MySQL57" --defaults-file="E://MySQL/mysql5.7/my.ini"

改密:
mysql -h127.0.0.1 -P3306 -uroot -p123456
update mysql.user set authentication_string=password('root') where user='root' and Host='localhost';
flush privileges;

#初始化
mysqld --defaults-file="E://MySQL/mysql8.0/my.ini" --initialize-insecure --user=mysql --console
flush privileges;
#服务
mysqld --install "MySQL80" --defaults-file="E://MySQL/mysql8.0/my.ini"

改密:
mysql -h127.0.0.1 -P3306 -uroot -p123456
ALTER user 'root'@'localhost' IDENTIFIED BY 'root';
ALTER USER ‘root’@‘localhost’ IDENTIFIED WITH mysql_native_password BY ‘root’;
flush privileges;

注意反斜杠E://

net start mysql
mysql -h127.0.0.1 -P3306 -uroot -p123456
use mysql;

mysql 5.7版本
update mysql.user set authentication_string=password('root') where user='root' and host='localhost';

mysql 8.0版本
ALTER user root@'localhost' identified by '123456';

flush privileges;

查看端口使用netstat -ano
删除服务mysqld remove MySQL57
CMD regedit
修改注册列表路径此电脑\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\MYSQL8修改路径
启动 net start MySQL57

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

kentrl

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值