MySQL create user authorization and backup

Original article: https://www.cnblogs.com/majj/p/9179218.html

authority management

We know that our highest authority administrator is the root user, it has the highest level operations. Including select, update, delete, update, grant and other operations. Then the general situation after the company DBA engineers will create a username and password, allowing you to connect to the database operations, and to the current user to set a permission (or all privileges) operations. So then we need to take a brief look:

  • How to create a user and password
  • To the current user authorization
  • Remove the current user's permissions

If you want to create a new user, you need the following:

1. Go to the next database mysql

mysql> use mysql
Database changed

2. For a new user additions and deletions

1 . Create a user:
 # specify ip: 192.118.1.1 of mjj user logs in 
the Create the User ' alex ' @ ' 192.118.1.1 ' IDENTIFIED by ' 123 ' ;
 # specify ip: 192.118.1 beginning mjj user logs in. 
The Create the User ' alex ' @ ' 192.118.1%. ' IDENTIFIED by ' 123 ' ;
 # specify any ip mjj user login 
the Create the user ' alex ' @ ' % ' IDENTIFIED by ' 123 ' ;

2Delete the user 
drop the User ' username ' @ ' IP address ' ;


 3 . Modify the user 
the rename the User ' username ' @ ' IP address ' to ' new user name ' @ ' IP address ' ;

 4 . Change Password 
the SET password for  ' username ' @ ' IP address ' = password ( ' new password ' );

3. The current user authorization management

# View Permissions 
Show Grants for  ' user ' @ ' IP address ' 

# authorized users only db1.t1 file mjj have query, insert and update operations 
Grant the SELECT, INSERT, ON db1.t1 Update to " alex " @ ' % ' ; 

# expressed all rights, in addition to grant this command, which is the root ago. mjj t1 user files under arbitrary operating db1 
Grant All privileges to db1.t1 ON " Alex " @ ' % ' ;
 # mjj user to perform any operations on the database file db1 
Grant db1 * All privileges to ON. " Alex " @ ' % ';
 # Mjj user has any operation on all database files 
Grant All privileges ON * * to. " Alex " @ ' % ' ; 
 
# cancel permission 
 
# cancel any operation t1 mjj user files on the db1 
REVOKE All ON db1.t1 from  ' alex ' @ " % " ;   

# cancel mjj user from a remote server all rights to the database db1 all tables 

REVOKE All oN db1. * from  ' alex ' @ " % " ;   

cancel mjj user from a remote server for all databases All rights table 
REVOKE All privileges ON *. * from  'alex'@'%';

4.MySql backup command line operation

# Backup: the data structure of the table + 
mysqdump -u the root DB1> db1.sql - P 


# backup: Data Table Structure 
mysqdump the root -d -u DB1> db1.sql - P 

# imported to a database existing data 
# 1 . to create a new database with 
the create database db10;
 # 2. import existing database files to the db10 database 
mysqdump -u root -d db10 <db1.sql -p

 

Guess you like

Origin www.cnblogs.com/wtil/p/11373513.html