MySQL creates users in three ways: INSERT user table method, create user method, Grant method. The form of account name account Number: User name + host (so duplicate user names can appear, unlike other databases) Username: within 16 characters. hostname: You can use the hostname and IP address, or you can use wildcards wildcard descriptions: 172.18.10.% (IP address is 172.18. All IP addresses in the 10 segment are accessible) second, create users nbsp Script: Create user ' username ' @ ' host ' [Identified by ' PASSWORD '] where the password is optional; Example: Create user ' john ' @ ' 192.168.189.71 ' IDENT Ified by "123"; CREATE USER ' john ' @ ' 192.168.189.% ' identified by "123"; CREATE USER ' john ' @ '% '; Description: The method created by the user is only connected to the database permissions, need to continue to authorize; Create user personal habits through the grant command This method is typically used to create a user, and grant grants the user authorization when the database exists. However, when the user is not present in the database, the appropriate user is created and authorized. (Note that the above step is superfluous) script: GRANT <all|priv1,priv2,..... privn> on [object] [identified by ' Password '] &nbs P [with GRANT OPTION]; Max_queries_per_hour Count max_updates_per_hour count max_connections_per_hour count Max_ User_connections count Description: Priv Delegate Permissions Select,insert,update,delete,create,drop,index,alter,gRant,references,reload,shutdown,process,file 14 rights Examples: Mysql>grant select,insert,update,delete,create, Drop on test.hr to [email protected] identified by ' 123 '; Description: Give the host 192.168.10.1 user John the ability to perform operations such as Select,insert,update,delete,create,drop on the HR table of the database test, and set the password to 123. Mysql>grant all privileges in test.* to [email protected] identified by ' 123 '; Description: Give the host 192.168.10.1 user John the ability to perform all operations on the database test all tables, and set the password to 123. Mysql>grant all privileges on * * to [email protected] identified by ' 123 '; Description: For the 192.168.10.1 user, John assigns permissions to all the tables in all databases and sets the password to 123. Mysql>grant all privileges on * * to [email protected] identified by ' 123 '; Description: User john assigns permissions to all operations on all tables in all databases and sets the password to 123. Four, directly to the Mysql.user table to insert records (this method is rarely used by individuals) because the database user information is stored in the Mysql.user table, so directly to the table INSERT statement, you can complete the user's creation; MySQL > INSERT into User (Host,user,password) values ('% ', ' John ', Password (' 123 ')); Five, after the completion of the user's creation, please remember to refresh the System permissions table; Mysql>flush privileges; &nBsp Summary: Although there are three ways to create a user, individuals are inclined to the second method, one step, simple and clear; The other two methods are only helpful to understand the principles of the database; ------------------------------------ --Split Line-------------------------------------- Ubuntu 14.04 install MySQL http://www.linuxidc.com/Linux/2014-05/ 102366.htm "MySQL authoritative guide (original 2nd edition)" Clear Chinese scanned PDF http://www.linuxidc.com/Linux/2014-03/98821.htm Ubuntu 14.04 LTS installation Lnmp nginx\php5 (PHP-FPM) \mysql http://www.linuxidc.com/Linux/2014-05/102351.htm Ubuntu 14.04 built MySQL master server http://www.linuxidc.com/Linux/2014-05/101599.htm Ubuntu 12.04 LTS build highly available Distributed MySQL Cluster/HTTP// www.linuxidc.com/Linux/2013-11/93019.htm Ubuntu 12.04 under source code installation MySQL5.6 and Python-mysqldb http://www.linuxidc.com /linux/2013-08/89270.htm MySQL-5.5.38 Universal binary installation http://www.linuxidc.com/Linux/2014-07/104509.htm ------- -------------------------------Split Line-------------------------------------- Permanent Update link address for this article:/http Www.linuxidc.com/Linux/2014-08/105954.htm
Ways to create a user 3 ways to create MySQL