How to Create Database and User MySQL Database on RHEL 7
How to Create Database and User MySQL Database on RHEL 7 |
How to Create Database and User MySQL Database on RHEL 7 - Hi everyone, on this occasion I will write my own little note so that in the future I don't forget, and in this article, I will write about some commands or syntax in MySQL.
Creating a MySQL database and user on Red Hat Enterprise Linux 7 (RHEL 7) is a fundamental step in setting up a robust and organized database environment. In this article, we will guide you through the process, providing clear and concise instructions to help you successfully establish a MySQL database along with a dedicated user account.
Whether you are a system administrator or a developer, understanding how to create and manage databases is crucial for the smooth operation of web applications and other software systems on your RHEL 7 server.
This article is simple but really helps me in doing my daily work. In this case, I am using Linux OS RHEL 7 and MySQL Commercial 8.0.13.
Login to MySQL Server
The first command you should know is "Login". To log in you can write the following command:
# mysql -u root -p
After that,t you enter your password.
Login to MySQL Server |
Listing all Databases
You can use the mysql command to take a look at the databases and to execute SQL queries on them. The screenshots below show you how. First, we log on to our MySQL server and execute the command show databases to see which databases exist on our MySQL server.
mysql> show databases;
Creating a Database
Now the next command that is no less important is "Creating a Database":
mysql> create database Bangkit;
Next, you can see what databases are on this MySQL server:
mysql> show databases;
Deleting a Database
When a database is no longer needed, you can permanently remove it with the drop database command, Or maybe you don't need the database, you can delete it by:
mysql> drop database Bangkit;
Create & Delete Database |
Accessing MySQL Server
Now, after you create a database like this, of course, you don't necessarily give root access to other people to be able to access the database.
Later in this article I will introduce create a user, granting access o that, user, and others.
Create User
To create a user, do the following:
mysql> create user 'kitsake'@'%' identified by '888Bangk!t';Then you can see if the user actually exists:
mysql> SELECT user,host FROM mysql.user;
Rename User
To rename a user, do the following:
mysql> rename user 'kitsake'@'%' to 'kitsake'@'192.168.1.%';
Then you can see if the user actually exists:
mysql> SELECT user,host FROM mysql.user;
Change Password
To change the password a user, do the following:
mysql> alter user 'kitsake'@'%' identified by '87490Bangk!t';
Give Access
Next, all you have to do is give access to the “kitsake” user to be able to access the “Bangkit” database.
mysql> GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, ALTER ON Bangkit.* TO 'kitsake'@'%';
And you can see if the user already has access by:
mysql> show grants for 'kitsake'@'%';
Create & Give Acces User Database |
Remove the Access
To remove the privileges that have been given you can use a syntax like this
mysql> REVOKE SELECT, INSERT, UPDATE, DELETE, CREATE, ALTER ON 'Bangkit'.* FROM 'kitsake'@'%';
Closing statement
In conclusion, mastering the creation of a MySQL database and user on RHEL 7 lays a solid foundation for efficient data management and application development. By following the steps outlined in this guide, users can confidently organize their databases, ensuring optimal performance and security.
Whether you are working on a small-scale project or a complex enterprise-level application, the ability to create and manage databases is a valuable skill. As technology advances, this foundational knowledge will continue to be essential for maintaining a reliable and scalable database infrastructure on Red Hat Enterprise Linux 7.
Maybe that's all I can write in this article, besides being a reminder for me, I hope this article is also useful and useful for those of you who have stopped by my blog.
Thank you.
Post a Comment for "How to Create Database and User MySQL Database on RHEL 7"
Post a Comment