最近在恢復阿里雲RDS數據庫,操做以下:mysql
1,下載備份文件linux
1,下載 Xtrabackup:sql
2,安裝依賴包:服務器
yum -y install perl perl-devel libaio libaio-devel perl-Time-HiRes perl-DBD-MySQL mysql-develapp
3,安裝 Xtrabackup:socket
rpm -ivh percona-xtrabackup-2.0.6-521.rhel6.x86_64.rpmide
4,將hins190855_xtra_20150312120203.tar.gz解壓到指定目錄(不會自動新建子目錄,要先設計好)阿里雲
mkdir /home/mysql/mysqldb cd /home/mysql/mysqldbspa
tar -izxvf hins190855_xtra_20150312120203.tar.gz
1,innobackupex --defaults-file=./backup-my.cnf --apply-log ./
2,刪除此目錄下的mysql,從新生成mysql系統庫從而擁有數據庫的root權限
rm -rf mysql #這裏刪除mysql目錄是爲了之後鏈接數據庫權限
3,更新目錄權限
chown -R mysql:mysql /home/mysql/mysqldb/ (備份文件所屬目錄) 並檢查文件所屬爲mysql用戶
[client]
default-character-set = utf8
[mysqld_multi]
mysqld = /usr/local/lnmp/mysql/bin/mysqld_safe
mysqladmin = /usr/local/lnmp/mysql/bin/bin/mysqladmin
user = root
[mysqld1]
port = 3306
socket = /tmp/mysql.sock
datadir = /date/lnmp/mysql
pid-file = /date/lnmp/mysql/mysql1.pid
log-error = /date/lnmp/log1/mysql_error.log
skip-locking
max_connections = 600
event_scheduler=ON
server-id = 1
[mysqld2]
port = 3307
socket = /tmp/mysql2.sock
datadir = /mysql2
pid-file = /mysql2/mysql.pid
log-error = /date/lnmp/log1/mysql_error2.log
innodb_data_file_path=ibdata1:200M:autoextend
innodb_log_files_in_group=2
innodb_log_file_size=1048576000 #這三行很重要,在/mysql2/mysql-my.cnf中有,複製過來就能夠了,否則innodb表打不開
啓動實例
/usr/local/lnmp/mysql/bin/mysqld_multi --defaults-file=/etc/my.cnf start 1
/usr/local/lnmp/mysql/bin/mysqld_multi --defaults-file=/etc/my.cnf start 2
中止實例方法
kill -9 `ps -ef | grep 3307 | grep -v grep | awk '{print $2}' | xargs`
修改mysql數據庫用戶名
mysql -uroot -proot -S /tmp/mysql2.sock
grant all on *.* to root@'localhost' identified by 'password'
4,以上第3步是針對一臺多個實例,若是就一個實例的話就不須要那麼麻煩了,第3步就是以下了:
vi /etc/my.cnf
/wdzj/lnmp/mysql/my.cnf
[client]
default-character-set = utf8
#password = your_password
port = 3306
socket = /wdzj/lnmp/mysql/mysql.sock
# Here follows entries for some specific programs
# The MySQL server
[mysqld]
port = 3306
socket = /wdzj/lnmp/mysql/mysql.sock
skip-external-locking
key_buffer_size = 16M
max_allowed_packet = 1M
table_open_cache = 64
sort_buffer_size = 512K
net_buffer_length = 8K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M
datadir = /home/mysql/mysqldb
max_connections=1000
innodb_data_file_path=ibdata1:200M:autoextend
innodb_log_files_in_group=2
innodb_log_file_size=1048576000
1, 重置ROOT密碼:
service mysql start
cd /wdzj/lnmp/mysql
./bin/mysqladmin -u root password 'linux'
2, 爲ROOT用戶賦權
grant all on *.* to root@'localhost' identified by 'linux' WITH GRANT OPTION;
flush privileges;
grant all on *.* to root@'%' identified by 'linux' WITH GRANT OPTION;
flush privileges;
(創建新用戶及賦權的語句要記得grant all privileges on test.test to test@localhost identified by 'test' ;)