How Can We Help?
How To Install MariaDB on Ubuntu 20.04 LTS
Notes for installing MariaDB on Ubuntu 20.04.
root@len:/var/www# apt update && sudo apt upgrade
root@len:/var/www# apt -y install software-properties-common
Reading package lists… Done
Building dependency tree
Reading state information… Done
software-properties-common is already the newest version (0.99.9.8).
0 to upgrade, 0 to newly install, 0 to remove and 0 not to upgrade.
root@len:/var/www#
apt-key adv –fetch-keys ‘https://mariadb.org/mariadb_release_signing_key.asc’
root@len:/var/www# apt-key adv –fetch-keys ‘https://mariadb.org/mariadb_release_signing_key.asc’
Executing: /tmp/apt-key-gpghome.J3PN2sGZod/gpg.1.sh –fetch-keys https://mariadb.org/mariadb_release_signing_key.asc
gpg: requesting key from ‘https://mariadb.org/mariadb_release_signing_key.asc’
gpg: key F1656F24C74CD1D8: public key “MariaDB Signing Key <signing-key@mariadb.org>” imported
gpg: Total number processed: 1
gpg: imported: 1
root@len:/var/www#
root@len:/var/www#
add-apt-repository ‘deb [arch=amd64] http://mariadb.mirror.globo.tech/repo/10.5/ubuntu focal main’
sudo apt update
sudo apt install mariadb-server mariadb-client
1 package can be upgraded. Run ‘apt list –upgradable’ to see it.
root@len:/var/www# apt list –upgradabale
E: Command line option –upgradabale is not understood in combination with the other options
root@len:/var/www# apt list –upgradabale
E: Command line option –upgradabale is not understood in combination with the other options
root@len:/var/www# apt list –upgradable
Listing… Done
mysql-common/unknown 1:10.5.15+maria~focal all [upgradable from: 5.8+1.0.5ubuntu2]
N: There are 3 additional versions. Please use the ‘-a’ switch to see them.
root@len:/var/www#
root@len:/var/www# apt list –upgradable -a
Listing… Done
mysql-common/unknown 1:10.5.15+maria~focal all [upgradable from: 5.8+1.0.5ubuntu2]
mysql-common/unknown 1:10.5.13+maria~focal all
mysql-common/unknown 1:10.5.12+maria~focal all
mysql-common/focal,focal,now 5.8+1.0.5ubuntu2 all [installed,upgradable to: 1:10.5.15+maria~focal]
root@len:/var/www#
apt install mariadb-server mariadb-client
root@len:/var/www# apt install mariadb-server mariadb-client
Reading package lists… Done
Building dependency tree
Reading state information… Done
The following additional packages will be installed:
galera-4 gawk libaio1 libcgi-fast-perl libcgi-pm-perl libdbd-mariadb-perl libdbi-perl libfcgi-perl libhtml-template-perl libmariadb3
libreadline5 libsigsegv2 libterm-readkey-perl mariadb-client-10.5 mariadb-client-core-10.5 mariadb-common mariadb-server-10.5
mariadb-server-core-10.5 socat
Suggested packages:
gawk-doc libclone-perl libmldbm-perl libnet-daemon-perl libsql-statement-perl libipc-sharedcache-perl mailx mariadb-test
The following NEW packages will be installed
galera-4 gawk libaio1 libcgi-fast-perl libcgi-pm-perl libdbd-mariadb-perl libdbi-perl libfcgi-perl libhtml-template-perl libmariadb3
libreadline5 libsigsegv2 libterm-readkey-perl mariadb-client mariadb-client-10.5 mariadb-client-core-10.5 mariadb-common mariadb-server
mariadb-server-10.5 mariadb-server-core-10.5 socat
0 to upgrade, 21 to newly install, 0 to remove and 1 not to upgrade.
Need to get 28.8 MB of archives.
After this operation, 224 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
… … ..
Setting up libreadline5:amd64 (5.2+dfsg-3build3) …
Setting up gawk (1:5.0.1+dfsg-1) …
Setting up libcgi-pm-perl (4.46-1) …
Setting up libhtml-template-perl (2.97-1) …
Setting up socat (1.7.3.3-2) …
Setting up libmariadb3:amd64 (1:10.5.15+maria~focal) …
Setting up libfcgi-perl (0.79-1) …
Setting up libterm-readkey-perl (2.38-1build1) …
Setting up libaio1:amd64 (0.3.112-5) …
Setting up libdbi-perl:amd64 (1.643-1ubuntu0.1) …
Setting up mariadb-server-core-10.5 (1:10.5.15+maria~focal) …
Setting up libcgi-fast-perl (1:2.15-1) …
Setting up libdbd-mariadb-perl (1.11-3ubuntu2) …
Setting up mariadb-client-core-10.5 (1:10.5.15+maria~focal) …
Setting up mariadb-client-10.5 (1:10.5.15+maria~focal) …
Setting up mariadb-client (1:10.5.15+maria~focal) …
Setting up mariadb-server-10.5 (1:10.5.15+maria~focal) …
Created symlink /etc/systemd/system/multi-user.target.wants/mariadb.service → /lib/systemd/system/mariadb.service.
Setting up mariadb-server (1:10.5.15+maria~focal) …
Processing triggers for libc-bin (2.31-0ubuntu9.7) …
Processing triggers for systemd (245.4-4ubuntu3.16) …
Processing triggers for man-db (2.9.1-1) …
Processing triggers for doc-base (0.10.9) …
Processing 1 added doc-base file…
root@len:/var/www#
next secure MariaDB Server by manually running the MySQL hardening script:
mysql_secure_installation
then check the mariadb database service is started automatically after installation:
root@len:~# systemctl status mysql
you can also use the command:
root@len:~# systemctl status mariadb
for same output:
● mariadb.service – MariaDB 10.5.15 database server
Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)
Drop-In: /etc/systemd/system/mariadb.service.d
└─migrated-from-my.cnf-settings.conf
Active: active (running) since Fri 2022-04-22 14:36:13 BST; 4min 16s ago
Docs: man:mariadbd(8)
https://mariadb.com/kb/en/library/systemd/
Main PID: 51723 (mariadbd)
Status: “Taking your SQL requests now…”
Tasks: 9 (limit: 9308)
Memory: 61.0M
CGroup: /system.slice/mariadb.service
└─51723 /usr/sbin/mariadbd
Apr 22 14:36:13 len mariadbd[51723]: 2022-04-22 14:36:13 0 [Note] /usr/sbin/mariadbd: ready for connections.
Apr 22 14:36:13 len mariadbd[51723]: Version: ‘10.5.15-MariaDB-1:10.5.15+maria~focal’ socket: ‘/run/mysqld/mysqld.sock’ port: 3306 mariadb.org>
Apr 22 14:36:13 len systemd[1]: Started MariaDB 10.5.15 database server.
Apr 22 14:36:13 len /etc/mysql/debian-start[51746]: Upgrading MySQL tables if necessary.
Apr 22 14:36:13 len /etc/mysql/debian-start[51749]: Looking for ‘mysql’ as: /usr/bin/mysql
Apr 22 14:36:13 len /etc/mysql/debian-start[51749]: Looking for ‘mysqlcheck’ as: /usr/bin/mysqlcheck
Apr 22 14:36:13 len /etc/mysql/debian-start[51749]: This installation of MariaDB is already upgraded to 10.5.15-MariaDB.
Apr 22 14:36:13 len /etc/mysql/debian-start[51749]: There is no need to run mysql_upgrade again for 10.5.15-MariaDB.
Apr 22 14:36:13 len /etc/mysql/debian-start[51749]: You can use –force if you still want to run mysql_upgrade
Apr 22 14:36:13 len /etc/mysql/debian-start[51757]: Checking for insecure root accounts.
~
~
Test your root login to MariaDB shell using the mysql client command:
mysql -u root -p
root@len:~# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 36
Server version: 10.5.15-MariaDB-1:10.5.15+maria~focal mariadb.org binary distribution
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.
MariaDB [(none)]>
you can check the version at any time by entering
MariaDB [(none)]> SELECT VERSION();
+—————————————+
| VERSION() |
+—————————————+
| 10.5.15-MariaDB-1:10.5.15+maria~focal |
+—————————————+
1 row in set (0.001 sec)
MariaDB [(none)]>
CREATE DATABASE wordpress DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
CREATE USER ‘wordpressuser’@localhost IDENTIFIED BY ‘*********’;
MariaDB [(none)]> CREATE DATABASE wordpress DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
Query OK, 1 row affected (0.001 sec)
NOTE! you have to use ” quote marks!!! for MariaDB – different quote marks to mysql!
MariaDB [(none)]> CREATE USER ‘wordpressuser’@localhost IDENTIFIED BY ‘****’;
Query OK, 0 rows affected (0.022 sec)
MariaDB [(none)]> GRANT ALL ON wordpress.* TO ‘wordpressuser’@’localhost’;
Query OK, 0 rows affected (0.021 sec)
MariaDB [(none)]> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.002 sec)
MariaDB [(none)]> CREATE DATABASE kevwells DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
Query OK, 1 row affected (0.001 sec)
MariaDB [(none)]> GRANT ALL ON kevwells.* TO ‘wordpressuser’@’localhost’;
Query OK, 0 rows affected (0.021 sec)
MariaDB [(none)]> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.001 sec)
MariaDB [(none)]>