一、准备环境
1.1 创建数据目录准备配置文件
[root@db data]
[root@db data]
[mysqld]
basedir=/application/mysql/
datadir=/data/3307/data
socket=/data/3307/data/mysql.sock
port=3307
log_err=/data/3307/mysql.err
log-bin=/data/3307/mysql-bin
server_id=7
[root@db data]
chown -R mysql:mysql /data
二、配置启动
2.1 初始化
[root@db data]
[root@db data]
[root@db data]
[root@db data]
/data
├── 3307
│ ├── data
│ ├── my.conf
│ ├── mysql-bin.000001
│ ├── mysql-bin.000002
│ ├── mysql-bin.000003
│ ├── mysql-bin.index
│ └── mysql.err
└── 3308
├── data
├── my.conf
├── mysql-bin.000001
├── mysql-bin.000002
├── mysql-bin.000003
├── mysql-bin.index
└── mysql.err
2.2 启动
[root@db data]
[root@db data]
[root@db data]
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1530/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1182/master
tcp 0 52 192.168.0.49:22 106.75.220.2:54310 ESTABLISHED 17531/sshd: root@pt
tcp 0 0 192.168.0.49:22 106.75.220.2:58731 ESTABLISHED 8275/sshd: root@pts
tcp6 0 0 :::22 :::* LISTEN 1530/sshd
tcp6 0 0 ::1:25 :::* LISTEN 1182/master
tcp6 0 0 :::3306 :::* LISTEN 17293/mysqld
tcp6 0 0 :::3307 :::* LISTEN 16924/mysqld
tcp6 0 0 :::3308 :::* LISTEN 17104/mysqld
2.3 修改密码
[root@db data]
Enter password:
Warning: Using a password on the command line interface can be insecure.
[root@db data]
Enter password:
Warning: Using a password on the command line interface can be insecure.
2.4 登陆确认
[root@db data]
Warning: Using a password on the command line interface can be insecure.
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| server_id | 7 |
+---------------+-------+
[root@db data]
Warning: Using a password on the command line interface can be insecure.
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| server_id | 8 |
+---------------+-------+
三、调优
3.1 配置启动脚本
[root@db data]
mysql -uroot -p3307 -S /data/3307/data/mysql.sock
[root@db data]
[root@db data]
mysql -uroot -p3308 -S /data/3308/data/mysql.sock
[root@db data]
[root@db data]
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 5.6.40-log Source distribution
Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
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> show variables like 'server_id';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| server_id | 7 |
+---------------+-------+
1 row in set (0.00 sec)
[root@db data]
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.6.40-log Source distribution
Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
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> show variables like 'server_id';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| server_id | 8 |
+---------------+-------+
1 row in set (0.00 sec)