MySQL Account related

Source: Internet
Author: User
Tags flush insert connect mysql

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!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.