1、下載安裝包
10年積累的成都網(wǎng)站制作、成都網(wǎng)站設(shè)計經(jīng)驗,可以快速應(yīng)對客戶對網(wǎng)站的新想法和需求。提供各種問題對應(yīng)的解決方案。讓選擇我們的客戶得到更好、更有力的網(wǎng)絡(luò)服務(wù)。我雖然不認識你,你也不認識我。但先建設(shè)網(wǎng)站后付款的網(wǎng)站建設(shè)流程,更有靖遠免費網(wǎng)站建設(shè)讓你可以放心的選擇與我們合作。wget ?https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-8.0.18-el7-x86_64.tar.gz
rpm?-qa?|grep??mysql rpm?-qa?|grep?mariadb rpm?-e?--nodeps?mariadb-libs-5.5.60-1.el7_5.x86_64
3、修改配置文件
cat?/etc/my.cnf [mysql] default-character-set=utf8 [mysqld] skip-name-resolve port?=?3306 basedir=/usr/local/mysql datadir=/usr/local/mysql/data max_connections=200 character-set-server=utf8 default-storage-engine=INNODB lower_case_table_names=1 max_allowed_packet=16M log-bin=master-bin???????????#master是master-bin,slave的是slave-bin server-id=1???????????#master為1,slave2 gtid_mode=ON enforce_gtid_consistency=ON binlog_checksum=NONE
4、初始化數(shù)據(jù)庫
groupadd?mysql useradd?-r?-g?mysql?-s?/bin/false?mysql cd?/usr/local tar?xvf?mysql-8.0.18-el7-x86_64.tar.gz ln?-s?mysql-8.0.18-el7-x86_64?mysql cd?mysql mkdir?mysql-files chown?mysql:mysql?mysql-files chmod?750?mysql-files bin/mysqld?--initialize?--user=mysql bin/mysql_ssl_rsa_setup bin/mysqld_safe?--user=mysql?& cp?support-files/mysql.server?/etc/init.d/mysql.server
記住數(shù)據(jù)庫的隨機密碼
#關(guān)閉命令
bin/mysqladmin -u root -p? shutdown
#啟動命令
bin/mysqld_safe --user=mysql &
5、設(shè)置環(huán)境變量:
cat??/etc/profile.d/msyql MYSQL_HOME=/usr/local/mysql/ export?PATH=$PATH:$MYSQL_HOME/bin
6、修改隨機密碼:
mysql? -u root? -p??? ????????????????????????#輸入初始化隨機生成的密碼
ALTER USER 'root'@'localhost' IDENTIFIED BY 'hello123';? ?
show master status;????? ????????? ? ? ? ? #查看master狀態(tài)
7、為主從復(fù)制創(chuàng)建用戶
CREATE USER 'econage'@'%' IDENTIFIED BY 'hello123';? ?
GRANT REPLICATION SLAVE ON *.* TO econage@'%';
#mysql8 之前的版本中加密規(guī)則是mysql_native_password,而在mysql8之后,加密規(guī)則是caching_sha2_password,把mysql用戶登錄密碼加密規(guī)則還原成mysql_native_password. 不然會報錯如下
#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';??? #添加這一條命令即可
FLUSH PRIVILEGES;
8、查看連接是否正確:
mysql?? -ueconage?? -phello123? -h292.168.0.56?? -e?? 'status;'
9、在slave進行連接master:
CHANGE MASTER TO
? MASTER_HOST='192.168.0.56',???????????? ????????#master主機ip
? MASTER_USER='econage', ??? ??? ??? ??? ?????????? #上面創(chuàng)建的用戶
? MASTER_PASSWORD='hello123',?? ??? ??? ? ??? #用戶密碼
? MASTER_LOG_FILE='master-bin.000002',?? ? #master的file文件名
? MASTER_LOG_POS=474;?? ??? ??? ??? ??? ??????????? # master的Position號
查看
show? slave? status\G????? #可能會狀態(tài)不對,執(zhí)行下面命令
stop? slave;
start? slave;
顯示兩個yes則正確。
10、驗證
#分別在master和slave查看
show?? databases;?????
#在master去創(chuàng)建一個庫
create? database? hello??
#會發(fā)現(xiàn)slave上也有一個hello的庫
文章名稱:Linux二進制包安裝Mysql8主從復(fù)制-創(chuàng)新互聯(lián)
分享路徑:http://aaarwkj.com/article16/dgohgg.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供虛擬主機、搜索引擎優(yōu)化、用戶體驗、動態(tài)網(wǎng)站、定制網(wǎng)站、營銷型網(wǎng)站建設(shè)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容