Database and User Creation in MariaDB on CentOS/Red Hat
The previous post we saw installation of MariaDB on CentOS 7. In this article, we discuss the steps for Database creation and granting the user privileges on databases.
After installing the MariaDB/MySQL on CentOS/RHEL 7, the next step is to create Database and User Creation using MySQL commands. This is a regular important task in administration.
Here we show the basic commands for database creation and its users, by providing all the privileges to the local.
To connect or interact with DB server, we have standard client which is installed along with MariaDB server, (MariaDB client is used for connecting the server from terminal.)
Here we’re connecting MariaDB with root privileges, follow the below commands to create DB username to connect the database server. Type the password and get into the database command line access.
Login with MariaDB root privileges.
|[[email protected] ~]# mysql -u root –p|
|Following commands to create and administrate the database.|
MariaDB [(none)]> show databases;
| Database |
| information_schema |
| mysql |
| performance_schema |
3 rows in set (0.00 sec)MariaDB [(none)]> create database zabbix_database character set utf8;
Query OK, 1 row affected (0.00 sec)MariaDB [(none)]> grant all privileges on zabbix_database.* to [email protected] identified by ‘password’;
Query OK, 0 rows affected (0.00 sec)MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> exit
MariaDB Commands to create Database and granting the permissions to user:
1. show databases; To show all databases in DB server.
2. create database zabbix_database character set utf8; To Create a database with specified name and character size.
3. grant all privileges on zabbix_database.* to [email protected] identified by ‘password’; This command is to provide the permission and creating the local user in a database.
4. flush privileges; To see the list of privileges provided to the specific user. This command is very useful when we grant any permissions to the existing or new user for any specific database.
5. exit; to exit from MySQL/MariaDB command line.
Conclusion : Using these commands we can create Database and User in MariaDB on Mysql/MariaDB server. Here I have created the database in the name of zabbix_database and Zabbix user for the local database. follow the commands and create your own database and user. for more Mysql/MariaDB commands follow my next articles.
Have a great day.