Home Guides Glossary

How to Create a MySQL User

MySQL is currently one of the most popular relational database management systems (RDBMSs) in the world. MySQL is available for a variety of platforms, including Linux operating systems such as CentOS.

User names allow the system administrators in MySQL to control the access that each user has. Each end user should have an individual user name so that administrators can determine which user has performed a particular action. Adding users in MySQL is a routine administrator task that requires root access.

DIFFICULTY Basic - 1 | Medium - 2 | Advanced - 3
TIME REQUIRED 5 min
RELATED PRODUCTS Linux-based VPS or dedicated servers

Here is a quick tutorial on how to add a new user in MySQL.

Log on to MySQL with root

Use the following command from the CentOS command line to log on to MySQL with the root user name:

# mysql -u root -p

Enter the password for root when prompted.

Create the MySQL user name and quit MySQL

Create the user ‘testuser' for the host ‘localhost' with the password ‘testpassword':

mysql> create user 'testuser'@'localhost' identified by 'testpassword';
mysql> quit

Log on to MySQL with the user name

Verify that you have successfully created the user name by logging back in to MySQL with the user name that you just created:

# mysql -u testuser -p

Enter the password 'testpassword' when prompted.

The above commands should produce output similar to the following:

Domain Registration

Pay less for website domain names. Register your own .com, .net or .org for as low as $10.18 per year. We have everything you need to get online with your new domain.

Website Builder

Build an amazing website in just under an hour with Website Builder. Take advantage of designs created just for your industry and then customize them to reflect your one-of-a-kind idea.

Website Security

Protect your website and keep customers safe. Your comprehensive Website Security solution. Get peace of mind by securing your websites.

cPanel Hosting

Everything needed to give your website the high-performance home it deserves.  Protect transactions and secure your customer's data with a SSL Certificate
Copyright © 2005 - 2024.  All rights reserved.  Privacy Policy