Regular users connect to MySQL database from other hosts

Source: Internet
Author: User

First, the landing database

Mysql-u root-p [super User password];

Second, create a new user

CREATE USER ' username ' @ ' host ' identified by ' password ';

Parameter description:

1, Username: You will create the user name;

2, Host: Specify the user on which host can log on, if the local user is available localhost;

If you want the user to be able to log on from any remote host , you can use the wildcard character%;

    3、Password: The user's login password, password can be empty, if it is empty, the user can not require a password to log on to the server.

Third, to the user authorization

Grant privileges on Databasename.tablename to ' username ' @ ' host ';

Parameter description:

1, privileges: User's operation rights, such as,, SELECT INSERT UPDATE etc., if you want to grant the permission to useALL;

2, DatabaseName: database name;

3, TableName: Table name, if you want to grant the user the appropriate operation permissions on all databases and tables can be * represented, such as*.*。

A user authorized with the above command cannot authorize another user, and if you want the user to be authorized to do so, use the following command:

GRANT privileges on Databasename.tablename to ' username ' @ ' host ' with GRANT OPTION;

Iv. Refreshing permission information

Flush privileges;

V. Restart the database

Service MySQL Restart

Vi. Connecting the database

mysql-h [Server address]-p [port number]-u [user name]-p [user password]

Vii. Supplementary Parts

1. Revoke Permissions

REVOKE privilege on Databasename.tablename from ' username ' @ ' host ';

2. Setting and changing user passwords

SET PASSWORD for ' username ' @ ' host ' = PASSWORD (' NewPassword ');

If the current user is logged in: SET PASSWORD = PASSWORD ("NewPassword");

3. Delete users

DROP USER ' username ' @ ' host ';

Regular users connect to MySQL database from other hosts

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.