Pre-Flight Check

These directions square measure meant for making a MySQL user on Linux via the statement.

I’ll be engaging from a Liquid net Core Managed CentOS half-dozen.5 server, and I’ll be logged in as root.

Login to MySQL

First we’ll login to the MySQL server from the command line with the following command:

[pastacode lang=”sql” manual=”mysql%20-u%20root%20-p” message=”MySQL” highlight=”” provider=”manual”/]

In this case, I’ve given the user root with the -u flag, thus used the -p flag so MySQL prompts for a positive identification. Enter your current positive identification to finish the login.

If you would like to vary your root (or any other) positive identification within the information, then follow this tutorial on dynamical a positive identification for MySQL via the command.

You should currently be at a MySQL prompt that appears terribly just like this:

[pastacode lang=”sql” manual=”mysql%3E” message=”MySQL” highlight=”” provider=”manual”/]

Create MySQL User

We’ll create a user with the name testuser , and the password test123test!.

[pastacode lang=”sql” manual=”CREATE%20USER%20’testuser’%40’localhost’%20IDENTIFIED%20BY%20’test123test!’%3B” message=”MySQL” highlight=”” provider=”manual”/]

That’s it, congratulations! In just one command you’ve created your first MySQL user. However, this user won’t be able to do anything with MySQL until they are granted additional privileges. In fact, they won’t even be able to login without additional permissions.

To give the new user proper permissions, work through our tutorial on granting permissions to MySQL user’s via the command line.

View a List of MySQL Users

Viewing a full list of MySQL users, including the host they’re associated with, can be done with the following select statement:

[pastacode lang=”sql” manual=”SELECT%20User%2CHost%20FROM%20mysql.user%3B” message=”MySQL” highlight=”” provider=”manual”/]

Output:

sql-users

Categorized in: