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
CMDregedit
修改注册列表路径此电脑\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\MYSQL8
修改路径
启动net start MySQL57