Common command mysql database

1, show databases; // check the database
show tables; // Display (first select the database before you can view the table: use database name)
Show Grants; // authorized to view the user's security permissions
show grants for 'user name' @ ' source address'; // view a user permissions
show status; // display a wide range of server status information
show errors; // display server error messages
show warnings; // display a warning message server
2, desc name of the database table name;. / / View data table structure
3, create database database name; // create a database
create table table name; // create a data table (first select the database)
4, drop database database name; // delete the database
drop table name of the database table. name; // delete the data in table
5, ( 'the value of a field' insert into table (one field, two fields, ......) (may be omitted) values, 'two field values', ... ...); // insert data into the data table
6, update the database table name field name set value = 1, 2 field name = value where the conditional expression; // change the original data
7, delete from the database name. table where the conditional expression; // delete unnecessary data
8, selec t Field 1, Field 2, ...... from table showing conditions where; // query
select user (); // display the currently connected users
select now (); // display the current time,
select user (), now () ; // display the current time and user
select database (); // display the current database
. 9, grant permissions list on the name of the database table name to 'user name '@' source address' identified by 'password'; // user permission settings
10, revoke privileges on the database name name table name from. 'username' @ 'source address'; // revoke user privileges
11, flush privileges; // refresh grant tables
12, help create databases; // display to create a specific database
help create tables; // create a specific display table
13, status; // display server status


Database backup and recovery:
Method a: direct backup directory / var / local / mysql / var
two: dedicated backup tools mysqldump

Backup:
mysqldump -u username -p password option watches the database name> / backup path / backup file name
Common Options:
--all-Databases
--opt


Recovery operations:
MySQL database name-uroot--p password </ backup path / backup file name

Guess you like

Origin www.cnblogs.com/lyqlyqlyq/p/11653462.html