MySQL创建用户以及授权
grant all on *.* to 'user1'@'localhost' identified by '123456';
grant SELECT,UPDATE,INSERT on db1.* to 'user2'@'192.168.174.1' identified by '123456';
grant all on db1.* to 'user3'@'%' identified by 'passwd';
show grants;
show grants for [email protected];
查询mysql当前有多少个用户
use mysql;
select user,host from user;
常用SQL语句
数据库引擎
select count(*) from mysql.user; //查看行数
select * from mysql.db\G;
select db from mysql.db;
select db,user from mysql.db;
select * from mysql.db where host like '192.168.%';
insert into db1.t1 values (1, 'abc');
update db1.t1 set name='aaa' where id=1;
truncate table db1.t1;
drop table db1.t1;
drop database db1;
MySQL数据库的备份与恢复
备份库 mysqldump -uroot -p123456 mysql > /tmp/mysql.sql
恢复库 mysql -uroot -p123456 mysql < /tmp/mysql.sql
备份表 mysqldump -uroot -p123456 mysql user > /tmp/user.sql
恢复表 mysql -uroot -p123456 mysql < /tmp/user.sql
备份所有库 mysqldump -uroot -p -A >/tmp/123.sql
只备份表结构 mysqldump -uroot -p123456 -d mysql > /tmp/mysql.sql
mysql -uroot -p123456 mysql -e create database mysql2;
mysql -uroot -p123456 mysql2 //直接进入mysql2库
扩展
SQL语句教程 http://blog.51cto.com/zt/206
什么是事务?事务的特性有哪些? http://blog.csdn.net/yenange/article/details/7556094
根据binlog恢复指定时间段的数据 http://www.centoscn.com/mysql/2015/0204/4630.html
mysql字符集调整 http://xjsunjie.blog.51cto.com/999372/1355013
使用xtrabackup备份innodb引擎的数据库 innobackupex 备份 Xtrabackup 增量备份