How To Install MariaDB on Ubuntu 22.04
In this guide, we will walk you through how to install MariaDB on Ubuntu 22.04, providing a robust database solution for your applications and projects.
Last updated
In this guide, we will walk you through how to install MariaDB on Ubuntu 22.04, providing a robust database solution for your applications and projects.
Last updated
MariaDB is a robust open-source relational database management system that emerged as a fork of MySQL. It is commonly used as a replacement for MySQL due to its fault tolerance, speed, and scalability.
Launch the Ubuntu 22.04 instance on Neevcloud
Access the server using SSH
First, ensure your package list is up to date to avoid any issues with outdated packages
Install the MariaDB package by running the following command
After installation, the MariaDB service starts and enables
Once the MariaDB is installed, start the MariaDB server
Enable it to start when the system rebooted
Verify that the database service is active and running. Run the following command
The network status of the MariaDB service can also be checked by running the ss
command at the terminal prompt
Running the mysql_secure_installation script is advisable to set up your database security levels and access privileges.
To secure MariaDB and access it, we must use the current credentials for login, and password required for the root user. If you recently set up MariaDB and If you haven't created the root password, simply hit the enter key at this point.
Setting the root password or using the unix_socket, You already have your root account protected, so you can safely answer 'n'.
You set the password of your root account and the password should be 8 to 10-bit.
By default, MariaDB installation has an anonymous user, if you want to remove the anonymous user press 'Y' otherwise and click 'n'.
if you disallow root login remotely press Y and otherwise click enter.
By Default. MariaDB comes with a database named 'test' that anyone can access. if you want to remove the test database press 'Y', otherwise 'n'.
All done! If you've completed all of the above steps, your MariaDB installation should now be secure. you can proceed to reopen MariaDB and revert the root user's authentication method to the default, auth_socket. To verify your identity as the main MySQL user with a password, execute this command
After executing the commands, please enter your password
To create a new MariaDB user, type the following command in the MariaDB console just like
[MariaDB (none)]>
Grant Privileges to MariaDB User
Once you have set up a new user, you can give them the necessary permissions.
To create a database in MariaDB, follow these steps:
Log into MariaDB with the command mysql -u username -p
. Replace username
with your MariaDB username. You'll be prompted to enter your password.
Once logged in, create a new database by executing CREATE DATABASE database_name;
. Replace database_name
with your desired database name.
To verify the database was created, use SHOW DATABASES;
. Your new database should appear in the list. To create a new database, run the following command from your MariaDB console just like MariaDB [(none)]>
User and database permission
Once you have set up a new user and database, you can give them the necessary permissions.
Now, review MariaDB configurations.
Now check the status databases to run these command