1. Create User (related table mysql.user)
localhost |
Root |
Natively |
127.0.0.1 |
Root |
Natively |
:: 1 |
Root |
Natively |
% |
Cheng |
Remote user (Any IP) |
192.168.1.55 |
Jake |
Remote user (Specify IP) |
1). Create a local user (native database can only be logged on natively)
Create user ' Cheng ' @ ' localhost ' identified by ' 123456 '; specify password ' 123456 '.
Insert into Mysql.user (Host,user,password) VALUES ("localhost", "Test", Password ("1234"));
The new version cannot be used in this way, and some fields will be prompted to not be empty. or create user convenience.
2). Create a remote user (other computer users can access the database through this user)
Create user ' name ' @ '% ' identified by ' password ';
"%" stands for any remote user
3). Modify the user password:
Update ' MySQL '. ' user ' Set password = password (' 123456 ') where user = ' Cheng ' and host = ' localhost ';
Set password for ' cheng ' @ ' localhost ' = password (' 778478635 ');
Set Password for = password (' 778478635 '); Change the password for yourself
4). mysql Login:
1 mysql-u root-h ip-p password Local login "-H IP" can be omitted.
2 default installed [email protected] User no password
3 Anonymous users only usage permissions, only login, no other permissions
5). Other:
1 GRANT USAGE on * * to ' @ ' localhost ' only allow login, no other permissions, minimum permissions
2 status (\s) view current various information
3 show character set; view Character set
4 SELECT * from MYSQL.USER\G display data by column
5 MySQL start with the default account is root and anonymous account, anonymous account is no matter what user name can log in
6 "Create User Jake" equals create user ' Jake ' @ '% '; This user can log on from any remote client
7 Create user ' Cheng ' @ ' localhost ' identified by ' 123456 '; local Cheng Users
8 Create user ' Cheng ' @ ' 192.168.1.15 ' identified by ' 123456 '; Specify the Cheng user of the IP address
2. Rights Management
1). User authorization:
1 Grant Select,alter on ' cheng ' @ ' localhost ' identified by ' 123 '
2 Grant all (privileges) on ' cheng ' @ ' localhost ' granting full privileges
3 GRANT Select on ' MySQL '. ' user ' to ' www ' @ ' localhost ' only has SELECT permission for user table
4 GRANT USAGE on *. discuz ' @ ' localhost ' identified by PASSWORD (login right only)
5 "*. *" represents all tables for all libraries, or you can specify the library to specify the table "Mysql.user".
The 6 Grant statement is followed by a "with GRANT option" to indicate that the associated table is also granted authorization.
7 grant a non-existent user name that is created directly to the user
2). Revoke User Rights
Revoke all on mysql.user from ' Cheng ' @ ' localhost ';
Revoke select,update on Mysql.user from ' Cheng ' @ ' localhost ';
3). View Specified user rights
Show grants for [email protected];//Specify user permissions
Show grants;
Show grants for current_user;//view your permissions
Show grants for Current_User ();
3. Delete users
1 drop user ' Jake ' @ ' localhost ';//delete database
2 drop table tb_name;//Delete tables
3 Drop database db_name;//Delete databases
4. Other
1), Eclipse link Database
Show View--Data Source Explorer
Database Connections new Databases link
Select MySQL Driver "Mysql-connector-java-5.1.8-bin.jar"
2), after login, source Filename.sql (EXECUTE statement, import external data)
This article is from a "sword Siege" blog, please make sure to keep this source http://weijiancheng.blog.51cto.com/10190955/1698219
MySQL User & Rights Management