User Management
Mysql> Grant All on * * to ' user1 ' @ ' 127.0.0.1 ' identified by ' 123456 '; # #创建用户并授权mysql > Grant Select,update,insert on db1.* to ' user2 ' @ ' 127.0.0.1 ' identified by ' passwd ';mysql> grant all O n db1.* to ' User3 ' @ ' percent ' identified by ' passwd ';mysql> show grants; # #查看授权mysql > Show grants for [e-mail protected];mysql> GRANT all privileges on * * to ' user1 ' @ ' 127.0.0.1 ' identified by PASSWORD ' *6bb4837eb74329105ee4568dda7dc67ed2ca2ad9 '; # #创建用户
Common Statements
Mysql> select count (*) from mysql.user; # #查看库mysql的表usermysql > select * from mysql.db\g; # #查看表内所有内容mysql > select db from mysql.db; # #查看db表里的dbmysql > select db,user from mysql.db; ## View db and usermysql> select * from mysql.db where host like ' in the DB table 127.0.0.% '; # #模糊查询mysql > insert into db1.t1 values (1, ' abc '); # #向表内插入数据mysql > update db1.t1 set name= ' aaa ' where id=1; # #更改表内数据mysql > truncate table db1.t1; ## Clear Table mysql> drop table db1.t1; # #删除表mysql > drop database db1; # #删除库
Backup and Recovery
[[email protected] ~]# mysqldump -uroot - p88888888 mysql > /tmp/mysql.sql # #备份库 [[Email protected] ~]# mysql -uroot -p88888888 mysql < /tmp/mysql.sql # #恢复库 [[email protected] ~]# mysqldump -uroot -p88888888 mysql user > /tmp/user.sql # #备份表 [[email protected] ~]# mysql -uroot -p88888888 mysql < /tmp/user.sql ## Restore Table [[email protected] ~]# mysqldump -uroot -p -a >/tmp/123.sql # #备份所有库Enter password: [[email protected] ~]# mysqldump -uroot -p88888888 -d mysql > /tmp/ mysql.sql # #只备份表结构
This article is from the "Gorilla City" blog, please be sure to keep this source http://juispan.blog.51cto.com/943137/1958501
MySQL common operations (bottom)