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
Set 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
Enable unix_socket authentication? [Y/n]
For the time being enter n
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';