In this article, we will discuss how to install MySQL on centos.MySQL is an open-source relational database management system. It is the most used database application in the world. now MySQL is not a defaults database in the centos operating system, MariaDB is the default database application software.
Some prerequisites before installing MySQL
- The operating system of centos must be installed in the system
- user must have the sudo privileges
- Yum package manager
- You can use MySQL Yum software repository in centos which will help you to install the latest RPM packages related to MySQL in the system.
- Before installing the MySQL package in the system, update the system with the help of below command
sudo yum update
- After the system is successfully updated, use the below command to install and add MySQL Yum repository in the system so that you can install the latest version of MySQL.
# wget https://repo.mysql.com/mysql80-community-release-el8-1.noarch.rpm
- After installing and adding MySQL Yum repository to the system, update the system once as mentioned in the above command or run bellow command to enable MySQL Yum repository.
[root@centos8~]# dnf repolist enabled | grep “mysql.*-community.*”
Install MySQL Package In Linux
- Install the MySQL package in the system with the following command
[root@centos8~]# dnf module install mysql:8.0 -y
check MySQL Version
With the help of the following command, you can check the version of the MySQL server which was installed in the system.
[root@centos8 ~]# mysql –version
Starting the MySQL Server
- After MySQL package is successfully installed in the system, you can start MySQL service with the help of the following command .
[root@centos8 ~]#systemctl start mysqld
- with the help of below command you can start the permeant MySQL service so that even if you restart the system, the service of MySQL will automatically start until the manual stopped the service.
[root@centos8 ~]#systemctl enable –now mysqld
- You can verify the service of MySQL with the given below command.
[root@centos8 ~]#systemctl status mysqld
- allow to access MySQL Server from remote Hosts through firewall , when firewall is running in your system you must run the below command to access MySQL through firewall .
[root@centos8 ~]# firewall-cmd –add -service=mysql –permanent root@centos8 ~ ] # firewall-cmd –reload success
Find Temporary Password
- When you install the MySQL server in the system and then you start the service, you need a temporary password to login into the MySQL which you will find in the location below.
sudo grep ‘temporary password’ /var/log/mysqld.log
Securing the MySQL Installation
- if you install fresh MySQL server in the system, you have to run the following command to secure your MySQL server , with the help of below command you can set these services Password Validation Policy, remove anonymous users, Disallow Users remote login, remove test database and reload in your system .
[root@centos8 ~] # mysql_secure_installation
Login MySQL with root Account .
- You can login to MySQL with the help of the password that you set at the time of running the MYSQL_ SECURE_INSTALLATION script.
Create Database in the MySQL
After login successfully in MySQL you can create databases and tables, Import exiting data backup, Create Users, etc.
what We Learned
In this article, we have tried to learn in detail about install MySQL on centos and hope that now you will have cleared many doubts related to MySQL
If you have any doubt about this article, you can ask your questions OR feedback through comments or mail. Your feedback will help to make our website better.
Also Check This