Learn how to install MySQL on CentOS 7 with this comprehensive guide. Follow our step-by-step instructions to set up and configure MySQL efficiently on your CentOS 7 system. #centlinux #linux #mysql
Table of Contents
What is MySQL?
MySQL Server Community Edition (CE) is the free version of world’s most popular open source database server. It is distributed under GPL License and supported by a large and active community of open source developers. There is also a commercial version of MySQL server, which is developed and maintained by Oracle Corporation.
Read Also: How to install MariaDB on Rocky Linux 9
MySQL Server 8 Community Edition Features
Main features of MySQL Server CE are.
- Supports SQL and NoSQL
- Pluggable Storage Engine Architecture
- MySQL Replication
- MySQL InnoDB Cluster
- MySQL Router
- MySQL Partitioning
- MySQL Workbench
Checkout complete list of MySQL Server 8 features at MySQL official website.

Linux Server Specification
We have configured a CentOS 7 virtual machine with following specifications.
- CPU – 3.4 Ghz (2 cores)
- Memory – 2 GB
- Storage – 20 GB
- Operating System – CentOS 7.6
- Hostname – mysql-server.example.com
- IP Address – 192.168.116.180/24
Install MySQL Yum Repository
Connect with mysql-server.example.com using ssh as root user.
Download and install MySQL yum repository from MySQL official website.
rpm -ivh https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
Output:
Retrieving https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
warning: /var/tmp/rpm-tmp.fJdAIJ: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:mysql80-community-release-el7-3 ################################# [100%]
Build cache for MySQL yum repository.
yum makecache fast
Recommended Training: The Ultimate MySQL Bootcamp: Go from SQL Beginner to Expert from Colt Steele

Install MySQL on CentOS 7
We have added the MySQL yum repository, now we can install MySQL on CentOS 7 and relevant packages using yum command.
yum install -y mysql-community-server
MySQL service is automatically enabled by the installer. Therefore, we are only required to start mysqld.service once.
systemctl start mysqld.service
During first start-up, MySQL service generates a temporary password in /var/log/mysqld.log file.
Retrieve this password using following command.
grep 'temporary password' /var/log/mysqld.log
Output:
2019-06-24T14:23:17.605740Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: B4gqaLFg6p_Y
Note down this password, we will use it later.
EPOMAKER X Aula F75 MAX Wireless Mechanical Keyboard with TFT Screen and Knob, Gasket Gaming Keyboard in 75% Layout, Hot Swappable, RGB Backlight, for PC/Mac/Linux (Black Gradient)
$66.99 (as of May 17, 2025 16:11 GMT +00:00 – More infoProduct prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on [relevant Amazon Site(s), as applicable] at the time of purchase will apply to the purchase of this product.)Securing MySQL Database Server
To configure and secure our MySQL database instance, we can use mysql_secure_installation command. We are also required to use temporary password to set a new password for root user.
mysql_secure_installation
Output:
Securing the MySQL server deployment.
Enter password for user root:
The existing password for the user account root has expired. Please set a new password.
New password:
Re-enter new password:
The 'validate_password' component is installed on the server.
The subsequent steps will run with the existing configuration
of the component.
Using existing password for root.
Estimated strength of the password: 100
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : Y
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.
Remove anonymous users? (Press y|Y for Yes, any other key for No) : Y
Success.
Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : Y
Success.
By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : Y
- Dropping test database...
Success.
- Removing privileges on test database...
Success.
Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : Y
Success.
All done!
Connect with MySQL database server using mysql command as root user.
mysql -u root -p
Display list of mysql databases.
show databases;
Output:
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.01 sec)
We have successfully install MySQL on CentOS 7.
Linux Basics for Hackers, 2nd Edition
$37.99 (as of May 17, 2025 16:11 GMT +00:00 – More infoProduct prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on [relevant Amazon Site(s), as applicable] at the time of purchase will apply to the purchase of this product.)Final Thoughts
Installing MySQL on CentOS 7 can be straightforward when you follow the right steps. This guide provides detailed instructions to help you set up and configure MySQL efficiently. If you encounter any challenges or need professional assistance, I offer expert services to help with your MySQL installation and configuration.
Your Linux servers deserve expert care! I provide reliable management and optimization services tailored to your needs. Discover how I can help on Fiverr!
Thank you for following this guide, and I look forward to assisting you with your MySQL projects!
Leave a Reply
You must be logged in to post a comment.