1
2
|
update mysql.user set Show_db_priv= 'Y' where user= 'navy' ; flush privileges; |
1
|
mysqladmin -h 127.0.0.1 -uroot -p123456 --sock=logs /mysql .sock variables |
1
|
mysqladmin -h 127.0.0.1 -uroot -p123456 --sock=logs /mysql .sock -i 5 processlist |
1
|
mysqladmin -uroot -p reload |
1
|
. /bin/mysqladmin -h 127.0.0.1 -uroot -pking+5688 --sock=logs /mysql .sock kill 610(610为processlist看到的sql ID号) |
1
|
. /bin/mysqldump -h 127.0.0.1 -P 3307 --sock=logs /mysql .sock navy2 > /data/navy2 .sql |
1
|
. /bin/mysqldump -h 127.0.0.1 -P 3307 --sock=logs /mysql .sock navy2 test > /data/test .sql |
1
2
|
. /bin/mysql -h 127.0.0.1 -uroot -pking+5688 --sock=logs /mysql .sock navy1 < /data/navy2 .sql(方法一) use navy1; source /data/navy2 .sql(方法二) |
1
2
|
MyisAM :支持全文索引,压缩索引,键值分离,一般用在读上面 InnoDB: 支持事务,键值在一起被缓存在innodb缓存池里,一般用在写或读写 |
1
2
|
mysql>show binary logs; mysql>purge binary logs to 'mysql-bin.000055' ; 从最原始清理到这个点 |
1
|
flush logs; |
1
|
mysql> show engines; |
1
|
mysql> show variables like '%storage_engine%' ; |
1
2
3
4
5
6
|
查看数据库的字符集: show variables like 'character%' ; 修改数据库的字符集: alter database mydb character set utf8; 创建数据库时指定字符集: create database mydb character set utf8; |
1
|
flush tables with read lock; |
1
|
unlock tables; |
1
2
3
4
5
6
7
8
9
10
|
查看master的binlog信息 show master statusG 查看同步信息 show slave statusG 选择同步点,主库ip是192.168.0.117,端口3307,同步账号slave,密码123456,主库binlog文件mysql-bin.000067,偏移点107 change master to master_host= '192.168.0.117' , master_Port=3307, master_user= 'slave' , master_password= '123456' , master_log_file= 'mysql-bin.000067' , master_log_pos=107; 创建账号slave,密码123456,权限“replication slave”,开放ip是192.168.0.119的账号 grant replication slave on *.* to slave@192.168.0.119 identified by "123456" ; 删除账号 drop user slave@192.168.0.119; |
1
|
SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1; |
1
|
mysqlbinlog mysql-bin.000006 > /data/sql_bak/6 .sql |
1
2
3
4
5
6
7
8
9
|
1. kill 掉系统里的mysql进程 ( ps | grep mysqld) 2.用以下命令启动mysql,以不检查权限的方式启动 /usr/local/mysql/bin/mysqld_safe --skip-grant-tables & 3.然后用空密码方式使用root用户登录mysql mysql -u root 4.修改root用户的密码: mysql> update mysql.user set password=PASSWORD( '310126' )where User= 'root' ; mysql> quit 5.重新启动mysql,就可以用新密码登录了 |
1
2
3
4
5
|
grant select ,insert,update,delete on newdatabase.* to newdatabase_pro@ '10.10.0.%' Identified by "123456“;(应用程序连的用户) grant all on newdatabase.* to newdatabase@10.10.0.100 Identified by "123456" ;(管理员用户) grant replication slave on *.* to slave@10.10.0.10 identified by "123456" ;(主从复制用户) grant replication client on *.* to repl_cli@ '192.168.0.%' identified by "123456" ;(监控用户) flush privileges;(刷新权限) |