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. )
- 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