MySQL create user and authorization, common SQL statements, MySQL database backup recovery

Source: Internet
Author: User
Tags mysql create custom name mysql create user

MySQL create user and authorize

Create User: Grant all on . to ' user1 ' @ ' IP address ' identified by ' passwd '; (User1 can be a custom user name, passwd is a password.) )
Grant to a user: Grant Select,update,insert on db1.* to ' user name ' @ ' User IP ' identified by ' password ';
View User rights: show grants;
: Show grants for user name @ ' User IP '

Common SQL statements

Query statements
1.select count () from library name. Table name; (count () indicates how many rows)
2.select from MySQL. library name; (View all data)
You can also search by field, as follows
Select db from Mysql.db; (single field)
Select Db,user from Mysql.db; (multiple fields, middle with "," separated)
Select
from mysql.db where host like ' 192.168.% '; (Fuzzy query)

Insert statement
1.insert into library name. Table name values (ID, ' name '); (ID and name are custom names.) The name is a string, and the string is enclosed in single quotes, and the number is not added. )

    1. Update library name. Table Name set name= ' custom name ' where id= a custom name; (change a row of a table)
      3.truncate table db1.t1; (empty, try not to use it.) )
MySQL Database backup recovery

Mysqldump-u User name-p password mysql >/tmp/mysql.sql backup Library
Mysql-u User name-p password MySQL </tmp/mysql.sql recovery Library
Mysqldump-u Username-p password library name table name >/tmp/user.sql table Backup (library name and table name are separated by spaces, first library table)
Mysql-u username-p password MySQL </tmp/user.sql recovery table (Restore table without writing table name, write library name directly)
Mysqldump-u User name-p password-A (all) >/tmp/123.sql back up all libraries
Mysqldump-u User-p password-d mysql >/tmp/mysql.sql only backup table structure

MySQL create user and authorization, common SQL statements, MySQL database backup recovery

Related Article

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.