mysql用户管理、sql语句、sql备份恢复

13.4 mysql用户管理

  1. grant all on . to 'user1' identified by 'passwd';
  2. grant SELECT,UPDATE,INSERT on db1.* to 'user2'@'192.168.133.1' identified by 'passwd';
  3. grant all on db1.* to 'user3'@'%' identified by 'passwd';
  4. show grants;
  5. show grants for user2@192.168.133.1;

13.5 经常使用sql语句

  1. select count(*) from mysql.user;
  2. select * from mysql.db;
  3. select db from mysql.db;
  4. select db,user from mysql.db;
  5. select * from mysql.db where host like '192.168.%';
  6. insert into db1.t1 values (1, 'abc');
  7. update db1.t1 set name='aaa' where id=1;
  8. truncate table db1.t1;
  9. drop table db1.t1;
  10. drop database db1;

13.6 mysql数据库备份恢复

  1. 备份库 mysqldump -uroot -p123456 mysql > /tmp/mysql.sql
  2. 恢复库 mysql -uroot -p123456 mysql < /tmp/mysql.sql
  3. 备份表 mysqldump -uroot -p123456 mysql user > /tmp/user.sql
  4. 恢复表 mysql -uroot -p123456 mysql < /tmp/user.sql
  5. 备份全部库 mysqldump -uroot -p -A >/tmp/123.sql
  6. 只备份表结构 mysqldump -uroot -p123456 -d mysql > /tmp/mysql.sql

扩展

  1. SQL语句教程 http://blog.51cto.com/zt/206
  2. 什么是事务?事务的特性有哪些? http://blog.csdn.net/yenange/article/details/7556094
  3. 根据binlog恢复指定时间段的数据 http://www.centoscn.com/mysql/2015/0204/4630.html
  4. mysql字符集调整 http://xjsunjie.blog.51cto.com/999372/1355013
  5. 使用xtrabackup备份innodb引擎的数据库 innobackupex 备份 Xtrabackup 增量备份 http://zhangguangzhi.top/2017/08/23/innobackex%E5%B7%A5%E5%85%B7%E5%A4%87%E4%BB%BDmysql%E6%95%B0%E6%8D%AE/#%E4%B8%89%E3%80%81%E5%BC%80%E5%A7%8B%E6%81%A2%E5%A4%8Dmysql
  6. 相关视频
    连接:http://pan.baidu.com/s/1miFpS9M 密码:86dx
    连接:http://pan.baidu.com/s/1o7GXBBW 密码:ue2f
相关文章
相关标签/搜索