in ,

Install MariaDB And Create Your First Database On Linux Just in Simple 3 Steps

Install MariaDB And Create Your First Database On Linux Just in Simple 3 Steps

While building your Web application Environment, i.e., LAMP (Linux, Apache, MySQL/MariaDB, PHP/Python) stack, you will need to install MariaDB, the community version that forked of MySQL Database.

Install MariaDB On Linux

To install MariaDB, you will need to run the following command

For Ubuntu

# apt-get install mariadb-server mariadb-client

For Redhat / CentOS

# yum install mariadb-server

OR use dnf with RHEL 8 and CentOS 8

# dnf install mariadb-server

Check and Enable MariaDB Service

By default, MariaDB will start automatically after the installation process is finishing, and we can run the below command to check the current MariaDB service status

# systemctl status mariadb

The output will be similar to the below screenshot with Active (running) status

Install MariaDB Server

But if the service status is inactive (dead), start the service using:

# systemctl start mariadb

And To enable MariaDB service for auto-start

# systemctl enable mariadb

MariaDB Basic Secure Step

To apply basic security and hardening of the MariaDB server, you need to run the command mysql_secure_installation and Interact with outputs as the following:

1- Set root password… [Set your root password].

2- Remove Anonymous users from MariaDB… [Y].

3- Disallow root login remotely feature… [Y].

4- Remove test database and access to it… [Y].

5- Reload privilege tables… [Y].

root@server ~ # mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none):
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n] y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
 ... Success!


By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] y
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] y
 ... Success!

By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] y
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

Create MariaDB First Your and Database

Login to the MariaDB server console, using the root credential with the password you created above, and replace PassWord with yours.

root@server ~ # mysql -uroot -pPassWord
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 771702
Server version: 10.3.32-MariaDB-0ubuntu0.20.04.1 Ubuntu 20.04

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]>

Now:

1- Create your first Database, i.e., create your WordPress CMS Installation Database, which called wordpress by running the following command in the MariaDB console.

MariaDB [(none)]> create database wordpress;

2- Create your wordpress Database user credential: username and password

MariaDB [(none)]> GRANT ALL PRIVILEGES ON worpress.* TO 'wordpress_db_username'@'localhost' IDENTIFIED BY 'wordpress_db_user_password';

3- Flush the MariaDB privileges

MariaDB [(none)]> FLUSH PRIVILEGES;

Then Exit

MariaDB [(none)]> exit
Bye

What do you think?

Leave a Reply

Your email address will not be published.

Cloudflare Apache ModEvasive

How To Harden Apache With ModEvasive While Using Cloudflare

Open Speed Test

Build Your Own Internet Speed Test Server Using Docker and Open Source Speedtest Tool