How To Add A New MySQL User, For Beginner Database Admin And Backend Developer

MySQL database logo


Adding new MySQL is not something we usually do on a daily basis as we are just stuck using a single user. I constantly forget how to add users because we don’t need to add users all the time. Maybe this article can help.

Here’s how you add a new user to your MySQL database using terminal.

1. Create new user with username newuser, and host localhost, it can be an IP address


CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'YourP@ssword123';


2. Add our new user permission, in this case we use asterisk symbol, mean this new user has root privileges


GRANT ALL PRIVILEGES ON * . * TO 'newuser'@'localhost';

3. Commit or Reload the changes


FLUSH PRIVILEGES;

Adding a new MySQL user is a very basic command, every database admin or developer must know these commands.

It’s much easier to add new user by using some database management tools like MySQL workbench, you don’t need to remember MySQL command, but it is sometimes you face some environment, server or cloud that doesn’t have GUI, so the only option you have to do is by using terminal.

4. Additional Information about MySQL

MySQL is the most used database system in the world, usually it is used for it is free and easy to install and easy to operate.

New developers usually choose MySQL as their first database to learn because that’s what it said in the majority of books or online tutorials, even me, when I first started in software development, the first database i use is MySQL.

Currently we have 2 different major versions of MySQL, version 5 and version 8. Sometimes upgrading from two different major versions is quite painful as there’s gonna be many changes in the system and is not backward compatible.

But if you want better performance and better security, it is highly recommended to upgrade to the newest database if possible. If you have time to fix your code to adapt to the new version.

Popular posts from this blog

ERROR 1348 Column Password Is Not Updatable When Updating MySQL Root Password

MIME Types - Complete List

Spring Kafka - how to use ReplyingKafkaTemplate send and reply synchronously

How To Connect SSH Using PEM Certificate On Windows

What Is My Localhost IP, For Windows User?