- 28 Views
- 20/10/2024
How to Install MySQL 5.7 on CentOS 7
Installing MySQL 5.7 on CentOS 7 involves several steps, starting from adding the official MySQL repository to securing your MySQL installation. Here's a step-by-step guide:
Step 1: Add the MySQL Yum Repository
First, you need to add the MySQL Yum repository to your system, which provides direct access to the latest updates and previous versions of MySQL.
1. **Download the MySQL Yum Repository package:**
2. **Check that the repository has been added successfully:**
### Step 2: Install MySQL
With the repository in place, you can install MySQL 5.7.
1. **Install MySQL:**
2. **Start the MySQL service:**
3. **Enable MySQL to start on boot:**
### Step 3: Configure MySQL
After installation, you need to perform some initial configuration tasks.
1. **Get the temporary password generated during the installation:**
This command retrieves the temporary password from the log files, which you'll need for initial login.
2. **Secure MySQL installation:**
Run the security script to set your root password and adjust other settings to secure your MySQL server.
You'll be prompted to enter the temporary password, change it to a new one, and make other security adjustments such as removing anonymous users and disabling root remote login.
### Step 4: Test MySQL Installation
Test your MySQL installation by logging in:
1. **Log into MySQL:**
Enter the root password when prompted. If you are logged in successfully, it means MySQL is properly installed and running.
### Step 5: Update Firewall Settings (Optional)
If you need to access MySQL from other computers, you must allow MySQL through the firewall.
1. **Update firewall settings to allow MySQL:**
sudo firewall-cmd --reload
This setup ensures MySQL 5.7 is installed and secured on your CentOS 7 system. If you encounter any issues during the installation, checking the MySQL log files at `/var/log/mysqld.log` can provide more detailed error information.
