In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
The following content mainly brings you Mysql8 master-slave copy installation method, the knowledge here is slightly different from books, are professional and technical personnel in the process of contact with users, summed up, has a certain experience sharing value, hope to bring help to the majority of readers.
1. Download the installation package
Wget https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-8.0.18-el7-x86_64.tar.gz
2. Delete the system with rpm-qa | grep mysqlrpm-qa | grep mariadbrpm-e-- nodeps mariadb-libs-5.5.60-1.el7_5.x86_64
3. Modify the configuration file
Cat / etc/ my.cnf [MySQL] default-character-set=utf8 [mysqld] skip-name-resolveport = 3306basedir=/usr/local/mysqldatadir=/usr/local/mysql/datamax_connections=200character-set-server=utf8default-storage-engine=INNODBlower_case_table_names=1max_allowed_packet=16Mlog-bin=master-bin # master is master-bin,slave is the slave-binserver-id=1 # master for the first slave2gtidhands modepieces for one for cephalopause gtidholders considering one Nbinlogically checksummed none
4. Initialize the database
Groupadd mysqluseradd-r-g mysql- s / bin/false mysqlcd / usr/localtar xvf mysql-8.0.18-el7-x86_64.tar.gzln-s mysql-8.0.18-el7-x86_64 mysqlcd mysqlmkdir mysql-fileschown mysql:mysql mysql-fileschmod 750mysql-filesbin/mysqld-initialize-user=mysqlbin/mysql_ssl_rsa_setupbin/mysqld_safe-user=mysql & cp support-files/mysql.server / etc/init.d/mysql.server
Remember the random password of the database
# close command
Bin/mysqladmin-u root-p shutdown
# start command
Bin/mysqld_safe-- user=mysql &
5. Set environment variables:
Cat / etc/profile.d/msyqlMYSQL_HOME=/usr/local/mysql/export PATH=$PATH:$MYSQL_HOME/bin
6. Modify the random password:
Mysql-u root-p # enter the password that initializes the randomly generated
ALTER USER 'root'@'localhost' IDENTIFIED BY' hello123'
Show master status; # View master status
7. Create a user for master-slave replication
CREATE USER 'econage'@'%' IDENTIFIED BY' hello123'
GRANT REPLICATION SLAVE ON *. * TO econage@'%'
In the previous version of # mysql8, the encryption rule is mysql_native_password, but after mysql8, the encryption rule is caching_sha2_password, which restores the mysql login password encryption rule to mysql_native_password. Otherwise, the error will be reported as follows
# error connecting to master 'econage@192.168.0.56:3306'-retry-time: 60 retries: 1 message: Authentication plugin' caching_sha2_password' reported error: Authentication requires secure connection.
ALTER USER 'econage'@'%' IDENTIFIED WITH mysql_native_password BY' hello123'; # just add this command
FLUSH PRIVILEGES
8. Check whether the connection is correct:
Mysql-ueconage-phello123-h292.168.0.56-e 'status;'
9. Connect to master in slave:
CHANGE MASTER TO
MASTER_HOST='192.168.0.56', # master Host ip
MASTER_USER='econage', # users created above
MASTER_PASSWORD='hello123', # user password
File file name of MASTER_LOG_FILE='master-bin.000002', # master
Position number of MASTER_LOG_POS=474; # master
View
Show slave status\ G # may be in the wrong state, execute the following command
Stop slave
Start slave
The display of two yes is correct.
10. Verification
# check it in master and slave respectively
Show databases
# create a library in master
Create database hello
# you will find that there is also a library of hello on slave
For the above Mysql8 master-slave replication installation method, if you need to know more, you can continue to pay attention to the innovation of our industry, if you need professional answers, you can contact the pre-sale and after-sale on the official website. I hope this article can bring you some knowledge updates.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.