1.mysql User creation:
shell> MySQL--user=root MySQL
Mysql> GRANT all privileges in *.* to monty@localhost identified by ' something ' with GRANT OPTION;
Mysql> GRANT all privileges in *.* to monty@ "%" identified by ' something ' with GRANT OPTION;
Mysql> GRANT reload,process on *.* to Admin@localhost;
Mysql> GRANT USAGE on *.* to Dummy@localhost;
These grant statements install 3 new users:
Monty
You can connect a full superuser from anywhere, but you must use a password ' something ' to do this. Note that we must issue a grant statement to Monty@localhost and monty@ "%". If we add a localhost entry, an entry created by mysql_install_db for the localhost anonymous user entry when we connect from the local host is preferred, because it has a more specific host field value, so it's an earlier arrival in the user table order.
Admin
Users who can connect from localhost without a password and are granted reload and process management privileges. This allows the user to perform mysqladmin reload, mysqladmin refresh and mysqladmin flush-* commands, as well as Mysqladmin processlist. No permissions are granted to the database. They can authorize it later by issuing another grant statement.
Dummy
A user can connect without a password, but only from the local host. Global permissions are set to ' N '--usage permission type allows you to set a user without permission. It assumes that you will grant database-related permissions at a later time.
2. Set user permissions by directly modifying the authorization table, and run these commands (note that flush privileges at the end):
shell> MySQL--user=root MySQL
Mysql> INSERT into User (Host,user,password) VALUES (' localhost ', ' Custom ', Password (' stupid '));
Mysql> INSERT into User (Host,user,password) VALUES (' Server.domain ', ' Custom ', Password (' stupid '));
Mysql> INSERT into User (Host,user,password) VALUES (' whitehouse.gov ', ' Custom ', Password (' stupid '));
Mysql> INSERT into db (Host,db,user,select_priv,insert_priv,update_priv,delete_priv, Create_priv,drop_priv)
VALUES (' localhost ', ' bankaccount ', ' Custom ', ' y ', ' y ', ' y ', ' y ', ' y ', ' y ');
Mysql> INSERT into DB
(Host,db,user,select_priv,insert_priv,update_priv,delete_priv, Create_priv,drop_priv)
VALUES (' whitehouse.gov ', ' expenses ', ' custom ', ' y ', ' y ', ' y ', ' y ', ' y ', ' y ');
Mysql> INSERT into db (Host,db,user,select_priv,insert_priv,update_priv,delete_priv, Create_priv,drop_priv)
VALUES ('% ', ' customer ', ' Custom ', ' y ', ' y ', ' y ', ' y ', ' y ', ' y ');
mysql> FLUSH privileges;
1 2 Next page > full text reading tips: Try "←→" button, turn the page more convenient Oh!