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:

MySQL
mysql -u root -p

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:

MySQL
mysql>

Create MySQL User

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

MySQL
CREATE USER 'testuser'@'localhost' IDENTIFIED BY 'test123test!';

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:

MySQL
SELECT User,Host FROM mysql.user;

Output:

sql-users

Categorized in: