MySQL is an open-source database management system, It uses a relational database and SQL (Structured Query Language) to manage its data.
Download and verify MySQL
In order to download MySQL, open the following URL in your browser:
Download bottom, and at the next page (If you don’t want to create an account) locate the text “
No thanks, just start my download” then “Right-click” and choose
copy the link location.
– Download MySQL
In your CentOS server, run the following command:
Note: you should edit the link in the following command with your new version.
– Verify the integrity of the downloaded file
Once the rpm file is saved, we will verify the integrity of the download by running
md5sum and comparing it with the corresponding MD5 value listed on the site:
Compare this output with the appropriate MD5 value on the site to verify that the file wasn’t corrupted or changed.
Install MySQL Server
First, we need to install the package:
rpm -ivh mysql80-community-release-el7-3.noarch.rpm
This adds two new MySQL yum repositories, and we can now use them to install MySQL server:
yum install mysql-server
y to confirm that you want to proceed.
– Starting MySQL Server
Start MySQL with the following command:
systemctl start mysqld
When installing MySQL on CentOS 7, a temporary root password is generated, you can find it using the following command:
grep 'temporary password' /var/log/mysqld.log
Make note of the password, which you will need in the next step to secure the installation.
– Change the temporary password
- use this command to run the security script:
2. Enter the temporary password and press
3. Now, type in a new strong password.
4. Follow the on-screen instructions and hit y to finish the setup.
– Connect to MySQL
Use the following command to connect to MySQL as root:
mysql -u root -p
Enter your MySQL root password and press
Connect to MySQL Remotly (Optional)
1. Create a user and grant it all privileges:
> CREATE USER 'root'@'%' IDENTIFIED BY 'your-password';
> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;
2. edit my.cnf file:
make sure that:
and if you have the line:
skip-networking, make sure to comment it.
Restart MySQL service:
systemctl restart mysqld.
3. Open the firewall port for MySQL:
MySQL by default use port 3306, you can use the following commands to open it
> firewall-cmd --add-port=3306/tcp --permanent
> firewall-cmd --reload
Now you can successfully connect to your MySQL server remotely.