In this instructional exercise, we will tell you the best way to introduce MySQL on CentOS. Bit by bit guidelines on the best way to design and introduce MySQL.
Alternative suggested read: How to Install MySQL on Ubuntu.
Prerequisites
Before we start, this you’ll need:
- A CentOS server. You can get one from Linode or Vultr. If you need an oversaw supplier, get a server from SolaDrive. They will introduce MySQL for you.
- Root access/sudo honors. All orders in this instructional exercise were executed with the root user
- By default, in CentOS 7, MySQL is excluded from the repos by any means. In CentOS 8 (and more up to date delivers) it is. We’ll incorporate guidelines for both use cases. MariaDB is remembered for all forms of CentOS.
How to Install MySQL on CentOS 7
Since MySQL is excluded from the CentOS 7 archives of course, we’ll need to add it to the repos first, and afterward introduce MySQL.
Step 1: Update the system
Update the stores/framework by running the accompanying command:
yum update
Step 2: Download and add the repo
Next, we want to download the MySQL repo. You can get the download interface from this page.
Once you get the download connect, use wget to download the file:
wget https://dev.mysql.com/get/mysql80-local area discharge el7-5.noarch.rpm
And now you can introduce the downloaded package:
rpm - ivh mysql80-local area discharge el7-5.noarch.rpm
Step 3: Install MySQL
And at long last, you can introduce MySQL by running the accompanying command:
yum introduce mysql-server
You can now begin and check the situation with the MySQL daemon with the accompanying commands:
systemctl start mysqld
systemctl status mysqld
And that is it. MySQL is introduced on your CentOS 7 server. The following stages are to get and arrange MySQL. The directions for that are below.
How to introduce MySQL on CentOS 8 (and later releases)
Starting with CentOS 8, MySQL is incorporated as a matter of course in the archives. So the establishment interaction is to some degree easier.
Step 1: Update the system
Run the accompanying order to refresh CentOS:
yum update
Step 2: Install MySQL
And introduce MySQL with the accompanying command:
yum introduce mysql-server
Start and check the situation with the MySQL daemon with the accompanying commands:
systemctl start mysqld
systemctl status mysqld
How to Optimize and Secure MySQL on CentOS
This is in no way, shape or form a broad instructional exercise on the most proficient method to get MySQL. There are significantly more arrangements and settings you ought to do to appropriately get MySQL on CentOS, as well as secure the server itself.
But, a speedy and simple method for getting a safer MySQL server is to run the security script, which will direct you through simple to-follow prompts.
Run the content with the accompanying command:
mysql_secure_installation
And follow the obvious prompts.
You can likewise streamline MySQL with MySQLTuner.
To fix and improve every one of your information bases without a moment’s delay, run the accompanying command:
mysqlcheck - A - - auto-fix - u root - p
And that’s it in a nutshell. You’ve presently introduced and designed MySQL on CentOS.