Format: Grant Select on database. * To User name @ login host identified by "password"
Example 1, add a user test1 password for ABC, so that he can log on any host, and all databases have query, insert, modify
, and delete permissions. First connect the root user to MySQL, and then type the following command:
| The code is as follows |
Copy Code |
Grant Select,insert,update,delete on *.* to test1@ "%" identified by "ABC"; |
But for example
1 added users are very dangerous and you want someone who knows Test1 's password so that he can be on the Internet any one
Computer login to your MySQL database and your data can do whatever you want, the solution is shown in Example 2.
Example 2, add a user test2 password for ABC, so that he can only log on localhost, and can query the database mydb, plug
Into, modify, delete operations (localhost refers to the local host, that is, the host of the MySQL database), so that users will use the known
Test2 's password, he cannot access the database directly from the Internet, only through a Web page on the MySQL host.
| The code is as follows |
Copy Code |
Grant Select,insert,update,delete on mydb.* to Test2@localhost identified by "ABC"; |
If you do not want to test2 the password, you can make another command to eliminate the password.
| The code is as follows |
Copy Code |
Grant Select,insert,update,delete on mydb.* to Test2@localhost identified by ""; |
In the last article we talked about logging in, adding users, changing passwords, and so on. Next, let's look at MySQL about database operations
Linux. Under Ubuntu start MySQL method:
| The code is as follows |
Copy Code |
/etc/init.d/sudo mysqld |
Two. Users add
Bin>mysql-u Root
mysql> Grant permission 1, permission 2,... Permission n on database name. Table name to User name @ user address identified by ' Connect password ';
Permission 1, permission 2,... Permission n represents 14 permissions, such as Select,insert,update,delete,create,drop,index,alter,grant,references,reload,shutdown,process,file.
When permission 1, permission 2,... Permission n is replaced by all privileges or all, giving the user full permissions.
When the database name. The table name is replaced by *.*, which indicates that the user is given permission to manipulate all tables on the server for all databases.
The user's address can be localhost, or it can be an IP address, machine name, domain name. You can also use '% ' to indicate a connection from any address.
' Connection password ' cannot be empty or the creation failed.
For example:
| The code is as follows |
Copy Code |
Mysql>grant Select,insert,update,delete,create,drop on Vtdc.employee to joe@10.163.225.87 identified by ' 123 '; |
Assign permissions to user Joe from 10.163.225.87 for operations such as Select,insert,update,delete,create,drop on the Database VTDC employee table, and set the password to 123.
| The code is as follows |
Copy Code |
Mysql>grant all privileges in vtdc.* to joe@10.163.225.87 identified by ' 123 '; |
Assign the user Joe from 10.163.225.87 the right to perform all operations on the database VTDC all tables, and set the password to 123.
| The code is as follows |
Copy Code |
Mysql>grant all privileges in *.* to joe@10.163.225.87 identified by ' 123 '; |
Assign the user Joe from 10.163.225.87 the right to perform all operations on all tables of all databases, and set the password to 123.
| The code is as follows |
Copy Code |
Mysql>grant all privileges in *.* to joe@localhost identified by ' 123 '; |
Assign the native user Joe the right to perform all operations on all tables of all databases, and set the password to 123.
If you want to give a specific user access to any machine on a given domain, you can issue a grant statement as follows:
| The code is as follows |
Copy Code |
Mysql> GRANT ... On *.* to myusername@ "%.mydomainname.com" identified by ' MyPassword ';
|
To do the same thing by directly modifying the authorization form, do this:
| The code is as follows |
Copy Code |
mysql> INSERT into user VALUES ('%.mydomainname.com ', ' MyUserName ', PASSWORD (' MyPassword '),...); mysql> FLUSH privileges;
|
You can also use Xmysqladmin, mysql_webadmin, and even xmysql to insert, change, and update values in the authorization table. You can find these utilities in the MySQL contrib directory.