Category: MariaDB Database

Added: 16th of June 2019

Viewed: 1326 times

Install MariaDB database in Ubuntu based distributions 2019

This is a four part series of tutorials.

MariaDB powers millions of databases. It can be found running at the back-end of blogs, shopping carts and many other online applications.

If you are interested in learning about basic database administration on Linux, it is handy to learn how to do this through the terminal. It will give you a better understanding of database administration tools such as PHPMyAdmin. PHPMYAdmin provides a GUI for the most common database tasks such as INSERT, UPDATE, and DELETE so you don't need to use the terminal.

This tutorial will show you how to install MariaDB in Ubuntu, Ubuntu based distributions.

Installing MariaDB. Open your terminal and enter the following command to install MariaDB package in your Linux distribution

sudo apt-get install mariadb-server

After installation, enter the following command.
sudo mysql_secure_installation

You will be asked the following questions to secure your MariaDB installation.

Enter current password for root (enter for none):
Since this is the first installation, just press enter

Change the root password? [Y/n] Y
It is always important to set a root password, so enter Y and press enter. You will then be prompted to enter a new password and the re-type the password

Remove anonymous users? [Y/n] Y
Enter Y and press enter

Disallow root login remotely? [Y/n] Y
Enter Y and press enter

Remove test database and access to it? [Y/n] Y
Enter Y and press enter

Reload privilege tables now? [Y/n] Y
Enter Y and press enter

After installation you will be greeted with the following message.

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

Thanks for using MariaDB!

Now we need to login to MariaDB database. In the terminal enter the following command
mysql -u root -p

You will be prompted for the password you enter earlier. If successful you will then be at the MariaDB prompt
MariaDB [(none)]>

I cannot login to MariaDB

If you enter your password and get the following message below, please enter sudo mysql_secure_installation in the terminal and go through the security questions again
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

If you are sure your password is correct, you probably need to update to root privaleges on MariaDB, so please try the following.

Enter the following in your terminal. Enter your root password which will make you a root user.
sudo su

Login to MariaDB database, using the password your created earlier.
mysql -u root -p

After this enter the following command replacing 'password' with your real password and press enter.
GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY 'password';

After this try to login again.

Other Tips & Tutorials

MariaDB Database

Perform basic SELECT queries in MariaDB using the Linux Terminal

Posted: 15th of September 2019

Views: 970

MariaDB Database

Create a new database, table and insert data, using MariaDB in the Linux Terminal

Posted: 12th of September 2019

Views: 949

MariaDB Database

Create a new user using MariaDB database in the Linux Terminal

Posted: 30th of June 2019

Views: 1298

MariaDB Database

Install MariaDB database in Ubuntu based distributions 2019

Posted: 16th of June 2019

Views: 1326

MariaDB Database

Create a new user in MariaDB and GRANT ALL privileges (Part 2)

Posted: 28th of May 2018

Views: 1341