In CentOS 7, yum list mysql * is used. There is no MySQL version that can be installed. In CentOS 7, the default database is MariaDB. For MariaDB, it is a branch of MySQL, the acquisition of MySQL by Oracle has the risk of closing the source, so there is a MariaDB branch that is compatible with MySQL. Below is how MySQL is installed through yum in CentOS 7.
Download Yum Repo package of MySQL Server 5.6
Yum install wget
Wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
Install mysql-community-release-el7-5.noarch.rpm package
Install this downloaded rpm package by using rpm command.
Rpm-ivh mysql-community-release-el7-5.noarch.rpm
After the installation of this package. We will get two new yum repo related to MySQL
[Root @ localhost ~] # Ls-1/etc/yum. repos. d/mysql-community *
/Etc/yum. repos. d/mysql-community.repo
/Etc/yum. repos. d/mysql-community-source.repo
[Root @ localhost ~] #
Installing MySQL Server
By using yum command, now we will install MySQL Server 5.6. All dependencies will be installed itself.
Yum install mysql-server
How to start/stop/restart MySQL Server
Now MySQL Server is installed on your system.
To start MySQL Service, run command
Systemctl start mysqld
To stop MySQL Service, run command
Systemctl stop mysqld
To restart MySQL Service, run command
Systemctl restart mysqld
To get status of MySQL Service, run command
Systemctl status mysqld
Reset MySQL root password
On fresh installation of MySQL Server. The MySQL root user password is blank.
For good security practice, we shoshould reset the password MySQL root user.
On newly installed MySQL Server, we generally recommend to use the command script. You have to just follow the instructions.
Mysql_secure_installation
In another method, you can log into MySQL server database and reset the password in secure way.
Mysql-u root
You will see mysql prompt like this mysql>. Use the below given commands to reset root's password.
Mysql> use mysql;
Mysql> update user set password = PASSWORD ("GIVE-NEW-ROOT-PASSWORD") where User = 'root ';
Mysql> flush privileges;
Mysql> quit