mySQL / MariaDB - Install MySQL on Linux

by
Jeremy Canfield |
Updated: March 30 2020
| mySQL / MariaDB articles
Use apt-get or yum to install the MySQL server. Be careful to observe if MySQL or MariaDB is installed. Some distributions will actually install MariaDB instead of MySQL.
apt-get install mysql-server
yum install mysql
Add the MySQL Authentication library modules to Apache:
apt-get install libapache2-mod-auth-mysql
Install the following package if your website will be using PHP:
apt-get install php5-mysql
Optional:
mysql_install_db/usr/bin/
Secure MySQL:
mysql_secure_installation
The ps command can be used to determine if your system is using init or systemd. If PID 1 is init, then you will use the service command. If PID 1 is systemd, then you will use the systemctl command.
If your system is using systemd, use the systemctl command to start and enable mysql.
systemctl enable mysql
systemctl start mysql
systemctl status mysql
If your system is using init, use the chkconfig and service commands to start and enable mysql.
chkconfig mysql on
service mysql start
service mysql status
Did you find this article helpful?
If so, consider buying me a coffee over at