直接看命令吧,懂得自然懂 。
(mysql-8.0.31-linux-glibc2.12-x86_64.tar
rpm -e postfix-2.10.1-9.el7.x86_64 mariadb-libs-5.5.68-1.el7.x86_64
mkdir /data/soft
cd /data/soft
wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.20-linux-glibc2.12-x86_64.tar.xz
tar -xvJf mysql-8.0.20-linux-glibc2.12-x86_64.tar.xz
mv mysql-8.0.20-linux-glibc2.12-x86_64 mysql8.0.20
groupadd mysql
useradd -g mysql mysql
chown -R mysql.mysql /data/soft/mysql8.0.20
mkdir /data/mysql
chmod 750 /data/mysql -R
mkdir /var/lib/mysql -p
chown mysql.mysql /var/lib/mysql -R
vi /etc/profile
export PATH=$PATH:/data/soft/mysql8.0.20/bin:/data/soft/mysql8.0.20/lib
[mysql]
default-character-set=utf8mb4
socket=/var/lib/mysql/mysql.socket
[client]
port=3306
socket=/var/lib/mysql/mysql.socket
[mysqld]
port=3306
server-id=2
user=mysql
general_log=1
general_log_file=/data/mysql/mysql.log
log-bin=mysql-bin
relay-log=mysql-relay
socket=/var/lib/mysql/mysql.socket
basedir=/data/soft/mysql8.0.20
datadir=/data/mysql
log-bin=/data/mysql/mysql-bin
innodb_data_home_dir=/data/mysql
innodb_log_group_home_dir=/data/mysql/
character-set-server=utf8mb4
lower_case_table_names=1
autocommit=1
symbolic-links=0
default_authentication_plugin=mysql_native_password
[mysqld_safe]
log-error=/data/mysql/mysql.log
pid-file=/data/mysql/mysql.pid
cd bin
./mysqld --user=mysql --basedir=/data/soft/mysql8.0.20 --datadir=/data/mysql --initialize
LT&d+<e9lfes
psKRLJ9rRk<h
cp -a ./support-files/mysql.server /etc/init.d/mysql
cp -a ./support-files/mysql.server /etc/init.d/mysqld
vi /etc/init.d/mysql
basedir=/data/soft/mysql8.0.20
datadir=/data/mysql
chown 777 /etc/my.cnf
chmod +x /etc/init.d/mysql
chmod +x /etc/init.d/mysqld
service mysql start
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'Xjsd2022';
use mysql
update user set host='%' where user='root';
flush privileges;
cd /data/soft/mysql8.0.20
cp /etc/init.d/mysql /etc/rc.d/init.d/mysql
CREATE USER 'repl'@'10.xx.10.%' IDENTIFIED WITH mysql_native_password BY 'repl1234';
GRANT REPLICATION SLAVE ON *.* TO 'repl'@'10.20xx.10.%';
CHANGE MASTER TO
MASTER_HOST='xxx',
MASTER_USER='repl',
MASTER_PASSWORD='repl1234',
MASTER_LOG_FILE='mysql-bin.000002',
MASTER_LOG_POS=2025;