Install MySQL5.7 with the Yum source of MySQL

Source: Internet
Author: User
Tags yum repolist

I. Installing the yum source with MySQL configuration


# Install the Yum source for MySQL, below is the RHEL6 series mysql5.6:

wget http://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm

The following are the RHEL6 series mysql5.7:

wget http://repo.mysql.com//mysql57-community-release-el6-8.noarch.rpm


Install the Yum source.

RPM-IVH mysql57-community-release-el6-8.noarch.rpm

Clear Cache

Yum Clean All


Here are some commands you can learn by the way

# Install Yum-config-manager

Yum Install Yum-utils-y

# Disable source for MySQL5.6

Yum-config-manager--disable mysql56-community

# Enable source for MySQL5.7

Yum-config-manager--enable MYSQL57-COMMUNITY-DMR

# Use the following command to see if the configuration is correct

Yum Repolist enabled | grep MySQL


Second, yum installation MySQL5.7

This version of the installation is 5.7.14, the test environment originally has 5.1.73 version, is the upgrade installation.

Yum install MySQL

650) this.width=650; "Src=" Http://s1.51cto.com/wyfs02/M00/85/47/wKiom1efBNuzwwpzAACgaANvhHI537.png-wh_500x0-wm_3 -wmp_4-s_2333914363.png "title=" qq picture 20160801161357.png "alt=" Wkiom1efbnuzwwpzaacgaanvhhi537.png-wh_50 "/>


Third, initialize and start MySQL

Service mysqld Start

The direct start service will make an error, as follows:
[[Email protected] lib]# service mysqld start
MySQL Daemon failed to start.
Starting mysqld: [Failed]

WORKAROUND: The new version requires MySQL to be initialized first.


Initialize MySQL


# mysqld--initialize--user=mysql--datadir=/var/lib/mysql

Or

# mysqld--initialize-insecure--user=mysql--datadir=/var/lib/mysql

In addition, you can remove the--user option from the command when you log in as a MySQL account and execute the program.

With official documentation we can know that if I am logged on to the Linux system as root, you can do this: mysqld--initialize--user=mysql or mysqld--initialize-insecure--user=mysql. If I am logging on to a Linux system with a MySQL user, you can do this: mysqld--initialize or Mysqld--initialize-insecure.


Regardless of the platform, the use of the--initialize option is installed in "Default Safe Mode" (that is, a random root initial password generation is included). In this case, the password is marked as expired and you need to select a new password. With the--initialize-insecure option, there is no root password generation, and if so, you need to specify the password for the account in a timely manner before the server is put into production use.


Using--initialize will generate a random initial password for the root account, we can use the command: Mysql-u root-p, and then enter the password to log in to MySQL. Using--initialize-insecure does not generate a random initial password for the root account, we can use the command: mysql-u root--skip-password log in to MySQL directly.


I encountered an error during initialization as follows:

[ERROR]--initialize specified but the data directory have files in it. Aborting.
[ERROR] Aborting


Workaround:

rm-rf/var/lib/mysql/*


Cause Analysis:


The MYSQLD service checks to see if the data directory exists, as follows:

If the data directory does not exist, MYSQLD creates it.

If the data directory exists and is not an empty directory (that is, contains a file or subdirectory), Mysqld displays an error message and aborts:

[ERROR]--initialize specified but the data directory exists. Aborting.

In this case, after you delete or rename the data Catalog, try again.


In summary: Before initializing, first check whether the data directory exists, execute the command: Ls-l/var/lib|grep MySQL. If so, execute the command:

Rm-rf/var/lib/mysql, remove it;

or execute the command: mv/var/lib/mysql/var/lib/newname, rename it to NewName, then you can.

Executes the initialization command again and executes successfully.


[Note] A temporary password is generated for [email protected]: ihey0gfhtt;f

Remember to initialize the generated temporary root password that will be used when logging in


After initialization is complete, start service mysqld directly





Iv. connecting MySQL and changing the password


A temporary root password is generated when initializing, and the password must be changed before the command can be executed.

Mysql-uroot-p Temporary password

After logging in, if you do not change the password immediately, execute the command times with the following error:

mysql> show databases;
ERROR 1820 (HY000): Must reset your password using ALTER USER statement before executing this statement.


Change Password: Set Password=password (' [email protected] ');

OR: Alter user ' root ' @ ' localhost ' identified by ' [email protected] ';

Execution succeeds again.



From the official documentation we learned that you can modify the password by using the ALTER USER statement. After logging in to MySQL, execute the statement:

Alter user ' root ' @ ' localhost ' identified by '[email protected]';

Change the password of the root account to [email protected] .

MySQL has enhanced user password security, so set the password must contain numbers, uppercase letters, lowercase letters, special symbols, if you set the password is too simple, you will be prompted:

ERROR 1819 (HY000): Your password does not satisfy the current policy requirements.








This article is from the "Technical Achievement Dream" blog, please be sure to keep this source http://pizibaidu.blog.51cto.com/1361909/1833587

Install MySQL5.7 with the Yum source of MySQL

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.