您好,登錄后才能下訂單哦!
本文主要給大家介紹操作MySQL的教程,文章內(nèi)容都是筆者用心摘選和編輯的,具有一定的針對(duì)性,對(duì)大家的參考意義還是比較大的,下面跟筆者一起了解下操作MySQL的教程吧。
#導(dǎo)入與還原數(shù)據(jù)庫(kù)
mysqldump -uroot -p zabbix > /root/zabbix.sql
還原數(shù)據(jù)庫(kù)
mysql -uroot -p zabbix < /root/zabbix.sql
#清理binlog
mysql -uroot -p
help purge
PURGE MASTER LOGS BEFORE '2003-04-02 22:46:26';
#更改 root密碼
service mysql stop
echo skip-grant-tables > /etc/my.conf
service mysql start
mysql
USR root;
UPDATE user SET Password = password ( '1q2w3e4r5t' ) WHERE User = 'root' ;
flush privileges ;
quit
vi /etc/my.conf
#skip-grant-tables
wq
#取消密碼復(fù)雜性
SHOW VARIABLES LIKE 'vali%'; #查看是否啟用了密碼復(fù)雜性
[mysqld]
validate_password=off
#安裝Precona
yum -y remove mysql-libs
yum install cronie cronie-anacron crontabs redhat-lsb-core sysstat
#yum -y install mysql-client mysql-server
#mysql config
#service mysql start
#chkconfig mysql on
yum install http://www.percona.com/downloads/percona-release/redhat/0.1-3/percona-release-0.1-3.noarch.rpm
yum install Percona-Server-shared-56 Percona-Server-client-56 Percona-Server-server-56
service mysqld start
chkconfig mysqld on #設(shè)置開機(jī)啟動(dòng)
MySQL -v #檢測(cè)MySQL版本
#mysqladmin -u root passwd root 給root設(shè)置數(shù)據(jù)庫(kù)密碼
===# 主從復(fù)制========================================
#打開Master數(shù)據(jù)庫(kù) my.conf文件
vi /etc/my.conf
server_id=1
binlog_format=ROW
binlog_row_p_w_picpath=minimal
#設(shè)置需要備份的數(shù)據(jù)庫(kù)
binlog-do-db=db_01
binlog-do-db=db_02
expire-logs-days=7 #保留7天的二進(jìn)制日志
binlog_format=MIXED #設(shè)置binlog格式為MIXED
log-bin = mysql-bin #開啟MYSQL二進(jìn)制日志
wq
service mysql restart
mysql #進(jìn)入mysql
use ebdb_trans; #使用ebdb_trans數(shù)據(jù)庫(kù)
grant replication slave on *.* to 'backup'@'192.168.0.11'identified by '你的密碼'; #設(shè)置slave IP和登陸權(quán)限
flush privileges;
flush tables with read lock;
reset master;
show master status\G; #查看file、position 并記錄該值
exit
#備份master數(shù)據(jù)庫(kù)到slave
mysqldump ebdb_trans > /root/ebdb_trans.sql
#切換到slave并恢復(fù)數(shù)據(jù)庫(kù)
mysql ebdb_trans < /root/ebdb_trans
vi my.conf
server-id=2
replication-do-db=ebdb_trans #需要復(fù)制的數(shù)據(jù)庫(kù)名稱
slave-skip-errors=1032,1062,126,1114,1146,1048,1396 #自動(dòng)跳過的錯(cuò)誤代碼,以防復(fù)制出錯(cuò)被中斷
wq
mysql #指定主庫(kù)信息
reset slave;
change master to master_host='192.168.0.8',master_user='backup',master_password='28270033',master_log_file='mysql-bin.000001',master_log_pos=120;
start slave; #啟動(dòng)slave
show slave status\G; #檢查從庫(kù)狀態(tài) (Slave_IO_Running: Yes Slave_SQL_Running: Yes)file
===========================================================================
常見問題:
1. Slave_IO_Running:no
(1查看 my.conf ---server-id 是否與master相同;
(2查看server_UUID是否與master相同,如相同則修改/var/lib/mysql/auto.conf
進(jìn)入mysql
show variables like '%server_uuid%'
2. Slave_SQL_Running: no
停掉從庫(kù),并重新指定主庫(kù)信息,最后啟動(dòng)slave
看完以上關(guān)于操作MySQL的教程,很多讀者朋友肯定多少有一定的了解,如需獲取更多的行業(yè)知識(shí)信息 ,可以持續(xù)關(guān)注我們的行業(yè)資訊欄目的。
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。