Install MySQL on Linux with MariaDB
Installing MySQL on Fedora Linux using MariaDB. Since MySQL was sold to Oracle. MariaDB is a fork and open source version of MySQL.
Install MySQL on Fedora using MariaDB
$ sudo dnf install mariadb mariadb-server mariadb-devel
Start MariaDB
Run this to start the process:
$ sudo systemctl start mariadb
Later if you try to connect to MariaDB
and get this error:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket
This means that you didn’t start the process. Or you restarted the machine and the process didn’t start.
For reference:
- Stop:
sudo systemctl stop mariadb
- Restart:
sudo systemctl restart mariadb
- Status:
sudo systemctl status mariadb
- Start at boot:
sudo systemctl enable mariadb
This the output of checking status with sudo systemctl status mariadb
:
mariadb.service - MariaDB 10.5 database server
Loaded: loaded (/usr/lib/systemd/system/mariadb.service; disabled; vendor preset: disabled)
Active: active (running) since Wed 2021-05-05 09:24:50 EDT; 9min ago
Docs: man:mysqld(8)
https://mariadb.com/kb/en/library/systemd/
Process: 1137071 ExecStartPre=/usr/libexec/mysql-check-socket (code=exited, status=0/SUCCESS)
Process: 1137094 ExecStartPre=/usr/libexec/mysql-prepare-db-dir mariadb.service
Process: 1137139 ExecStartPost=/usr/libexec/mysql-check-upgrade
Main PID: 1137129 (mysqld)
Status: "Taking your SQL requests now..."
Tasks: 8 (limit: 9124)
Memory: 124.4M
CPU: 343ms
CGroup: /system.slice/mariadb.service
Config MariaDB
$ sudo mysql_secure_installation
In order to log into MariaDB to secure it, we’ll need the current password for the root user. If you’ve just installed MariaDB, and haven’t set the root password yet, you should just press enter here.
Enter current password for root (enter for none):
Setting the root password or using the unix_socket ensures that nobody can log into the MariaDB root user without the proper authorisation. You already have your root account protected, so you can safely answer ‘n’.
Switch to unix_socket authentication [Y/n] n
... skipping.
You already have your root account protected, so you can safely answer ‘n’.
Change the root password? [Y/n] n
... skipping.