服务器 | 端口 | 说明 |
---|---|---|
192.168.52.122 | 3306 | master |
mkdir /app
cd /app
wget https://cdn.mysql.com/archives/mysql-5.7/mysql-5.7.25-linux-glibc2.12-x86_64.tar.gz
tar -zxvf mysql-5.7.25-linux-glibc2.12-x86_64.tar.gz
mv mysql-5.7.25-linux-glibc2.12-x86_64 mysql-5.7.25
等待解压完毕后执行
groupadd mysql
useradd -r -g mysql mysql
cd /app/mysql-5.7.25
chown -R mysql:mysql ./
bin/mysqld --initialize --user=mysql --basedir=/app/mysql-5.7.25 --datadir=/app/mysql-5.7.25/data
生成了临时密码(ehAhDfgn97)O) 要复制出来,等会用
122节点默认密码,复制到txtx文本中,等会用
%ci5&rob2DAl
vim /etc/my.cnf
[mysqld]
character_set_server=utf8
init_connect='SET NAMES utf8'
basedir=/app/mysql-5.7.25
datadir=/app/mysql-5.7.25/data
socket=/tmp/mysql.sock
#忽略大小写
lower_case_table_names = 1
# 不开启严格模式
sql_mode = "STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
log-error=/var/log/mysqld.log
pid-file=/app/mysql-5.7.25/data/mysqld.pid
#开启日志
log-bin = mysql-bin
#设置服务id,主从不能一致 ,一般设置为ip最后一段
server-id = 122
#设置需要同步的数据库
binlog-do-db=pis_data
#屏蔽系统库同步
binlog-ignore-db=mysql
binlog-ignore-db=information_schema
binlog-ignore-db=performance_schema
cp /app/mysql-5.7.25/support-files/mysql.server /etc/init.d/mysqld
chkconfig --add mysqld
vim /etc/init.d/mysqld
添加路径 在46行
basedir=/app/mysql-5.7.25
datadir=/app/mysql-5.7.25/data/
service mysqld start
cd /app/mysql-5.7.25/bin
./mysql -uroot -p
%ci5&rob2DAl
alter user 'root'@'localhost' identified by '123456';
flush privileges;
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;