database:ubuntu_mariadb_install

Ubuntu Install MariaDB

I made a bash install script that is more precise and updated which does the same and more it can be found on my git server [here]

Run the following using sudo or root.

apt update
apt install -y mariadb-server mariadb-client
systemctl start mariadb.service
mysql_secure_installation

Apply the following when running mysql_secure_installation. Note mysql_secure_installation is not strictly needed anymore.

Enter current password for root (enter for none): press enter
Switch to unix_socket authentication [Y/n]        Y/n   optional but in 2025 it should be yes
Change the root password? [Y/n]                   Y/n   if socket is selected then select no
New password:                                     enter new root password
Re-enter new password:                            enter new root password again
Remove anonymous users?                           press y
Disallow root login remotely?                     press y
Remove test database and access to it?            press y
Reload privilege tables now?                      press y

Tweak your config as you see fit. I normally add the following as a bare minimum. Listen on all interfaces and skip-name-resolve for performance.

vi /etc/mysql/mariadb.conf.d/50-server.cnf

Find this line:

bind-address            = 127.0.0.1

Change it to:

bind-address            = 0.0.0.0

Optional Start

Skip dns lookups. Be warned though if you enable this 127.0.0.1 will no longer be treated as localhost. The whole idea of this was to speed up the database, but in mordern times things have improved and the tweak is mostly regarded as a legacy.

Add the folowing somewhere under [mysqld]

# custom sql settings
skip-name-resolve
# custom sql settings

Optional Stop

Restart mariadb for changes to take effect.

systemctl restart mariadb
database/ubuntu_mariadb_install.txt · Last modified: by Allan