Installing and configuring MySQL (MariaDB)

4 min readUpdated December 6, 2025

MySQL is a free relational database management system.

First, update the system package and repository lists:

bash
sudo apt-get -y update && sudo apt-get -y dist-upgrade

Add the MariaDB repository:

bash
curl -sS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | sudo bash

Install MariaDB:

bash
sudo apt-get -y install mariadb-server

Next, start the client using the following command:

bash
mysql -u root -p

The ";" character is required in SQL queries.

Select the MySQL system database:

sql
USE mysql;

Create the first user:

sql
CREATE USER 'spacecore'@'localhost' IDENTIFIED BY '123456';

Now create a database:

sql
CREATE DATABASE server;

Use the following two commands to grant the user access to the database:

sql
GRANT ALL PRIVILEGES ON server.* TO 'spacecore'@'localhost' WITH GRANT OPTION; FLUSH PRIVILEGES;

#Opening the database for external access

If you need to connect to MySQL from a host other than localhost, edit /etc/mysql/my.cnf and find the bind-address line so that it looks as follows:

ini
#bind-address = 127.0.0.1

Restart MySQL:

bash
service mysql-server restart

Did not find the answer? We are online 24/7.Contact support