Create a user in Linux MySQL

Source: Internet
Author: User

In the MySQL environment, the system for user authentication and authorization management is flexible and powerful. It not only manages what operations can be performed, but also controls the hosts from which users can connect to the server. This increases security.

My machine is a Linux system. When I first set up MySQL, the user name is root and the password is set by myself. First, log on to MySQL:

$ Mysql-u root-p ******

Then you can create a user:

Format:

$ Grant perssions on databases. tables to 'username' @ 'permittedhost' identified by 'Password' with grant option;

For example:

$ Grant all on mysql. user to 'user' @ 'localhost' identified by 'www .bkjia.com ';

In this way, a user Local login user is created with the password www.bkjia.com, which has all permissions on the user table in the mysql database.

In addition, because the new user is essentially the user table in mysql, you can also insert a user record to create the user:

For example:

$ Insert into user values ('localhost', 'user _ name', password ('www .bkjia.com '));

The result is the same as the preceding one. However, you must run a statement after the statement is executed:

$ Flush privileges;

This statement is used to refresh the table related to system permissions so that the newly created user takes effect.

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.