Use yum to install mysql and centosyum in CentOS 7.0

Source: Internet
Author: User

Use yum to install mysql and centosyum in CentOS 7.0

The default database of CentOS7 is mariadb, which is not used to the configuration. Therefore, it is decided to change it to mysql. However, the yum source of CentOS7 does not seem to have mysql by default. To solve this problem, we need to download the mysql repo source first.

1. Download the mysql repo Source

$ wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm

2. Install the mysql-community-release-el7-5.noarch.rpm package

$ sudo rpm -ivh mysql-community-release-el7-5.noarch.rpm

After installing this package, you will get the yum repo source for both mysql:/etc/yum. repos. d/mysql-community.repo,/etc/yum. repos. d/mysql-community-source.repo.

3. Install mysql

$ sudo yum install mysql-server

You can install it as prompted, but there is no password after installation, and you need to reset the password

4. Reset the mysql password

$ mysql -u root

The following ERROR may be reported during logon: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql. sock '(2), because of/var/lib/mysql access permission issues. The following command changes the owner of/var/lib/mysql to the current user:

$ sudo chown -R root:root /var/lib/mysql

Restart mysql Service

$ service mysqld restart

Next, log on to reset the password:

$ Mysql-u root // directly press enter to enter the mysql console mysql> use mysql; mysql> update user set password = password ('000000') where user = 'root '; mysql> exit;

 

Related Article

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.