MySQL common operations (bottom)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.