1. 程式人生 > >從阿里rds匯出資料庫和匯入自建資料庫的步驟

從阿里rds匯出資料庫和匯入自建資料庫的步驟

1. 根據rds選擇好安裝的版本
2  解除安裝原有的資料庫
rpm -qa | grep mysql
根據上面查詢的結果執行下一行的命令
rpm -ev --nodeps   XXXXX
yum remove MySQL-server MySQL-develrm –rf /usr/my.cnf
rm -rf /root/.mysql_sercret
rm -rf /etc/my.cnf
rm -rf /var/lib/mysql3  下載安裝包
wget http://dev.mysql.com/Downloads/MySQL-5.6/MySQL-server-5.6.21-1.rhel5.x86_64.rpm
wget http://dev.mysql.com/Downloads/MySQL-5.6/MySQL-devel-5.6.21-1.rhel5.x86_64.rpm
wget http://dev.mysql.com/Downloads/MySQL-5.6/MySQL-client-5.6.21-1.rhel5.x86_64.rpm
4  安裝rpm -ivh MySQL-server-5.6.21-1.rhel5.x86_64.rpm
rpm -ivh MySQL-client-5.6.21-1.rhel5.x86_64.rpm
rpm -ivh MySQL-devel-5.6.21-1.rhel5.x86_64.rpm
5、 修改配置檔案、初始化Mysql
  5.1、修改配置檔案路徑到etc目錄,命令:
 cp /usr/share/mysql/my-default.cnf /etc/my.cnf
  5.2、初始化Mysql ,命令:
/usr/bin/mysql_install_db6 、檢視mysql服務是否已經啟動,若沒有啟動,則啟動mysql:
ps -ef|grep mysql
netstat -anpt|grep 3306
service mysql start
7 因為Mysql安裝好後的初始預設密碼是一個隨機密碼,我們可能需要修改成我們自己設定的密碼:
  查詢預設密碼命令:
more /root/.mysql_secret  
看到初始密碼後,使用mysql -uroot -pj3R5qTNxrKsxnQTj 命令登入Mysql:(j3R5qTNxrKsxnQTj即為筆者查到的初始密碼)
set password = password('123456');
8  修改Mysql服務開機時自動啟動(不需要則略過)
chkconfig mysql on;
chkconfig mysql --list;
設定遠端root訪問許可權GRANT ALL PRIVILEGES ON *.* TO 'root'@'192.168.7.%' IDENTIFIED BY 'xxxx' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON *.* TO 'root'@'10.0.40.%' IDENTIFIED BY 'xxxx' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON *.* TO 'root'@'10.0.41.%' IDENTIFIED BY 'xxxx' WITH GRANT OPTION;flush privileges;9  在網站https://www.percona.com/downloads/XtraBackup/LATEST/ 下載相應的下版本percona-xtrabackup-2.2.10-1.el6.x86_64.rpm10 進行安裝和相應的依賴包
yum -y install perl perl-devel libaio libaio-devel perl-Time-HiRes perl-DBD-MySQL
wget ftp://rpmfind.net/linux/dag/redhat/el6/en/x86_64/dag/RPMS/libev-4.15-1.el6.rf.x86_64.rpm
rpm -ivh libev-4.15-1.el6.rf.x86_64.rpm
rpm -hiv percona-xtrabackup-24-2.4.9-1.el6.x86_64.rpm 11  根據阿里雲 https://help.aliyun.com/knowledge_detail/41817.html 提示進行恢復。