Http://www.cnblogs.com/cnblogsfans/archive/2009/09/21/1570942.html
Http://www.jb51.net/article/31902.htm
mysql> INSERT INTO Mysql.user (Host,user,password) VALUES ("localhost", "Test", Password ("1234"));
This creates a user named: Test with a password of: 1234.
Note: "localhost" here means that the user can only log on locally and cannot telnet to another machine. If you want to telnet, change "localhost" to "%", which means you can log on on any computer. You can also specify that a machine can log on remotely.
Authorizing a user
Authorization format: Grant permissions on database. * To User name @ login host identified by "password";
- Log in to MySQL (with root) and log in as root here:
@>mysql-u root-p
@> Password
- First create a database (TestDB) for the user:
Mysql>create database TestDB;
- The authorization test user has all the permissions of the TestDB database (all permissions for a database):
Mysql>grant all privileges in testdb.* to [e-mail protected] identified by ' 1234 ';
Mysql>flush privileges;//Refresh System Permissions Table
Format: Grant permissions on database. * To User name @ login host identified by "password";
- If you want to specify partial permissions to a user, you can write:
Mysql>grant select,update on testdb.* to [e-mail protected] identified by ' 1234 ';
Mysql>flush privileges; Refresh System Permissions Table
- The authorization test user has some permissions for all databases:
Mysql>grant Select,delete,update,create,drop on * * To test@ "%" identified by "1234";
The test user has Select,delete,update,create,drop permissions on all databases.
@ "%" indicates authorization for all non-local hosts, excluding localhost. (The localhost address is set to 127.0.0.1, if set to the real local address, do not know whether it can, no authentication.) )
Authorization to localhost: plus a grant all privileges on testdb.* to [email protected] identified by ' 1234 ';
MySQL related configuration