Linux centosvmware MySQL user management, common SQL statements, MySQL database backup recovery

Source: Internet
Author: User
Tags create database

One, MySQL user management

Grant all on * * to ' user1 ' @ ' 127.0.0.1 ' identified by ' mimA123 '; Create User1 user

Sign in with User1

/usr/local/mysql/bin/mysql-uuser1-pmima123-h127.0.0.1

To localhost, without-H can also log in

Mysql> Grant All on * * to ' user1 ' @ ' localhost ' identified by ' mimA123 ';

[Email protected] ~]#/usr/local/mysql/bin/mysql-uuser1-pmima123

Grant Select,update,insert on db1.* to ' user1 ' @ ' 192.168.1.101 ' identified by ' mimA123 '; Authorized

Grant all on db1.* to ' user2 ' @ '% ' of ' identified by ' mimA123 '; Give any IP license, any IP in% instead of

Show grants;

Show grants for [email protected]; View specified user authorizations

II. Common SQL statements

Login to MySQL switch to DB1 library

Select COUNT (*) from Mysql.user; Inquire

SELECT * from Mysql.db;

The ENGINR used inside the MySQL library is MyISAM, which automatically helps to count how many rows

The library engine you created is InnoDB

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 '); Insert

Update db1.t1 set name= ' AAA ' where id=1; Change a row of a table

Delete data

Delete from db1.t1 where id=1;

TRUNCATE TABLE db1.t1; Clear the data table, the table is still

drop table db1.t1; Delete the table, all the table data is deleted

Drop database db1; Deleting a database

Third, MySQL database backup recovery

Create a new database Mysql2

/USR/LOCAL/MYSQL/BIN/MYSQL-UROOT-E "CREATE Database Mysql2"

Backup library mysqldump-uroot-pmima123 mysql >/tmp/mysql.sql

Recovery library mysql-uroot-pmima123 MySQL </tmp/mysql.sql

Backup table mysqldump-uroot-pmima123 mysql user >/tmp/user.sql

Recovery table mysql-uroot-pmima123 MySQL </tmp/user.sql

Back up all Libraries mysqldump-uroot-p-A >/tmp/123.sql

Back up table structure only mysqldump-uroot-pmima123-d mysql >/tmp/mysql.sql

Linux centosvmware MySQL user management, 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.