Example of installing MySQL database through yum in CentOS 7

Source: Internet
Author: User
Tags mysql version reset centos

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.