MySQL5.7版本单机多实例启动配置

1 编译安装MySQL

参考:https://blog.csdn.net/zhangh571354026/article/details/132125822?spm=1001.2014.3001.5502

2 相关处理

# groupadd mysql
# useradd -r -g mysql mysql
# rm -rf  /data/3308
# mkdir -p /data/3308
# chown -R mysql.mysql /data/3308
# cd /data/3308
# rm -rf /etc/my.cnf
# mysqld --initialize --basedir=/usr/local/mysql --datadir=/data/3308/ --user=mysql
2023-08-13T03:42:58.171311Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2023-08-13T03:42:58.571613Z 0 [Warning] InnoDB: New log files created, LSN=45790
2023-08-13T03:42:58.710972Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2023-08-13T03:42:58.782203Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 7eede6f7-398b-11ee-a010-08002774005a.
2023-08-13T03:42:58.784951Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2023-08-13T03:42:59.152448Z 0 [Warning] A deprecated TLS version TLSv1 is enabled. Please use TLSv1.2 or higher.
2023-08-13T03:42:59.152588Z 0 [Warning] A deprecated TLS version TLSv1.1 is enabled. Please use TLSv1.2 or higher.
2023-08-13T03:42:59.153171Z 0 [Warning] CA certificate ca.pem is self signed.
2023-08-13T03:42:59.201581Z 1 [Note] A temporary password is generated for root@localhost: tGtYe;B(X7;P

# touch my.cnf
# cat my.cnf
[client]
port=3308
socket=/data/3308/mysql.sock
default_character_set=utf8
​
[mysqld]
port=3308
socket=/data/3308/mysql.sock
datadir=/data/3308
log-error=/data/3308/error.log
pid-file=/data/3308/mysql.pid
character_set_server=utf8
lower_case_table_names=1
autocommit=1

# mysqld_safe --defaults-file=/data/3308/my.cnf &
[2] 1352688
root@book:/data/3308# Logging to '/data/3308/error.log'.
2023-08-13T03:46:21.790524Z mysqld_safe Starting mysqld daemon with databases from /data/3308

# lsof -i:3308
COMMAND     PID  USER   FD   TYPE   DEVICE SIZE/OFF NODE NAME
mysqld  1352847 mysql   18u  IPv6 11649289      0t0  TCP *:3308 (LISTEN)

# mysql -h 127.0.0.1 -u root -P3308 -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.42-debug

Copyright (c) 2000, 2023, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

3 配置my.cnf

[client]
port=3308
socket=/data/3308/mysql.sock
default_character_set=utf8
​
[mysqld]
port=3308
socket=/data/3308/mysql.sock
datadir=/data/3308
log-error=/data/3308/error.log
pid-file=/data/3308/mysql.pid
character_set_server=utf8
lower_case_table_names=1
autocommit=1

你可能感兴趣的:(MySQL,单机,多实例,5.7,my.cnf,启动)