Install, configure, and secure MariaDB on popular Linux distributions.
Update the package index and install gnupg, software-properties-common, and wget. These tools let you add MariaDB’s official repository and verify packages.
Run sudo mariadb-keyring install
to import GPG keys, then add the repo with sudo add-apt-repository 'deb [arch=amd64] https://mirror.mariadb.org/repo/10.11/ubuntu $(lsb_release -cs) main'
. Finally, update with sudo apt update
.
Enable the official YUM repo with sudo tee /etc/yum.repos.d/MariaDB.repo
(use MariaDB’s provided repo file). Then run sudo yum install mariadb-server mariadb
or sudo dnf install mariadb-server mariadb
.
After installing, enable the service: sudo systemctl enable mariadb
. Start it with sudo systemctl start mariadb
. Check status using sudo systemctl status mariadb
.
Execute sudo mysql_secure_installation
. Set a strong root password, remove anonymous users, disallow remote root logins, remove the test database, and reload privilege tables.
Log in with sudo mysql -u root -p
and run:CREATE DATABASE ecommerce; CREATE USER 'shop_admin'@'localhost' IDENTIFIED BY 'S3cur3!'; GRANT ALL ON ecommerce.* TO 'shop_admin'@'localhost'; FLUSH PRIVILEGES;
Connect as shop_admin
: mysql -u shop_admin -p ecommerce
. Create a sample table and insert a row to confirm reads/writes work.
Configure backups with mysqldump
or mariabackup
, tune /etc/mysql/mariadb.conf.d/50-server.cnf
for innodb_buffer_pool_size, enable the firewall for port 3306 only to trusted hosts, and monitor with mariadb-exporter
.
No. Both can coexist if listening on different sockets and ports, but package managers may remove MySQL client binaries. Plan migrations carefully.
Port 3306/TCP, the same as MySQL. Use firewalls or bind-address to restrict exposure.
Stop the service, remove packages via apt/yum/dnf, delete /var/lib/mysql, and remove configuration under /etc/mysql or /etc/my.cnf.d.