标签:
在操作MYSQL中注意两个概念:
干什么都记得 flush privileges;
grant all on *.* to root@‘localhost‘ identified by ‘password‘ WITH GRANT OPTION
记得要加WITH GRANT OPTION
=========================
2,RDS MySQL 使用开源软件 Xtrabackup 对 MySQL 数据库进行备份。需要下载该软件,然后使用该软件进行恢复。
将下载好的文件*.tar.gz 放到linux服务上
mkdir /mysql2/ cd /mysql2/
tar -izxvf *.tar.gz
innobackupex --defaults-file=./backup-my.cnf --apply-log ./
rm -rf mysql #这里删除mysql目录是为了以后连接数据库权限
3,关键在这里了,我们需要配置my.cnf ,如果说你之前linux服务器就已经有一个实例了,那么现在你还要创建一个实例(也就是一台多个mysql服务)
/usr/local/lnmp/mysql/bin/mysql_install_db --user=mysql --datadir=/mysql2/
vi /etc/my.cnf
[client]
default-character-set = utf8
[mysqld_multi]
mysqld = /mysql/bin/mysqld_safe
mysqladmin = /mysql/bin/bin/mysqladmin
user = root
[mysqld1]
port = 3306
socket = /tmp/mysql.sock
datadir = /date/
pid-file = /date/mysql1.pid
log-error = /date/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/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表打不开
启动实例
/mysql/bin/mysqld_multi --defaults-file=/etc/my.cnf start 1
/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 -pxxxx -S /tmp/mysql2.sock
grant all on *.* to root@‘localhost‘ identified by ‘xxxx‘ WITH GRANT OPTION
4,以上第3步是针对一台多个实例,如果就一个实例的话就不需要那么麻烦了,第3步就是如下了:
vi /etc/my.cnf
[mysqld]
********
innodb_data_file_path=ibdata1:200M:autoextend
innodb_log_files_in_group=2
innodb_log_file_size=1048576000
#只要加这三行就可以了
********
~~~~~~~~~~~~
重置密码的方法:
方法一:
1.关闭mysql
# service mysqld stop
2.屏蔽权限
# mysqld_safe --skip-grant-table
屏幕出现: Starting demo from .....
3.新开起一个终端输入
# mysql -u root mysql
mysql> UPDATE user SET Password=PASSWORD(‘newpassword‘) where USER=‘root‘;
mysql> FLUSH PRIVILEGES;//记得要这句话,否则如果关闭先前的终端,又会出现原来的错误
mysql> \q
~~~~~~~~~~~~~
还原时的注意事项:
The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
解决办法:
mysql> set global read_only=0;
(关掉新主库的只读属性)
flush privileges;
set global read_only=1;(读写属相)
flush privileges;
~~~~~~~~~~~~~~~~~
阿里的操作指南:
标签:
原文地址:http://www.cnblogs.com/aguncn/p/4313702.html