How to install MySQL database using MySQL yum source, yummysql5.7

Source: Internet
Author: User
Tags yum repolist

How to install MySQL database using MySQL yum source, yummysql5.7

1. install and configure the MySQL yum Source

# Install the MySQL yum source. The following is the RHEL6 series mysql5.6:

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

Below is 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

The following commands can be learned by the way:

Copy codeThe Code is as follows:
# Install yum-config-manager
Yum install yum-utils-y
# Disabling the source of MySQL5.6
Yum-config-manager -- disable mysql56-community
# Enable the source of MySQL5.7
Yum-config-manager -- enable mysql57-community-dmr
# Use the following command to check whether the configuration is correct
Yum repolist enabled | grep mysql

Ii. Install MySQL5.7 in yum

The version of this installation is 5.7.14. The test environment is 5.1.73 and is upgraded and installed.

Yum install mysql

Iii. initialize and start MySQL

Service mysqld start

An error is reported when you start the service directly as follows:

[Root @ localhost lib] # service mysqld start

MySQL Daemon failed to start.

Starting mysqld: [failed]

Solution: the new version requires that mysql be initialized first.

Initialize mysql

Copy codeThe Code is as follows:
# Mysqld -- initialize -- user = mysql -- datadir =/var/lib/mysql

Or

Copy codeThe Code is as follows:
# Mysqld -- initialize-insecure -- user = mysql -- datadir =/var/lib/mysql

In addition, you can remove the -- user option from the command when logging on to and executing the program using the mysql account.

We can see from the official documentation that If I log on to the Linux system as a root user, run mysqld -- initialize -- user = mysql or mysqld -- initialize-insecure -- user = mysql. If I log on to Linux as a mysql user, run mysqld -- initialize or mysqld -- initialize-insecure.

On any platform, the -- initialize option is installed in "default security mode" (including the generation of a random root initial password ). In this case, the password is marked as expired, and you need to select a new password. Use the -- initialize-insecure option without generating a root password. If so, you need to specify a password for your account in time before the server is put into production.

Run -- initialize to generate a random initial password for the root account. Run mysql-u root-p and enter the password to log on to MySQL. Using -- initialize-insecure will not generate a random initial password for the root account. We can use the command: mysql-u root -- skip-password to directly log on to MySQL.

I encountered the following error during initialization:

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

Solution:

Copy codeThe Code is as follows:
Rm-rf/var/lib/mysql /*

Cause analysis:

The mysqld service checks whether the data directory exists as follows:
If the data directory does not exist, mysqld will create it.
If the data directory exists and is not an empty directory (including files or subdirectories), mysqld displays an error message and suspends:
[ERROR] -- initialize specified but the data directory exists. Aborting.
In this case, delete or rename the data directory and try again.

Before initialization, check whether the data directory exists and run the command ls-l/var/lib | grep mysql. If yes, run the following command:

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

You can also run the following command: mv/var/lib/mysql/var/lib/newname and rename it as newname.
Run the initialization command again.

[Note] A temporary password is generated for root @ localhost: ihey0gFhTT; f

Remember the temporary root Password generated during initialization, which will be used during logon.

After initialization, start service mysqld start directly.

4. Connect to MySQL and change the password

During initialization, a temporary root password is generated. After logon, you must change the password before executing the command.

Copy codeThe Code is as follows:
Mysql-uroot-p temporary password

If you do not change the password immediately after logging on, the following error is reported when you run the command:

Mysql> show databases;

ERROR 1820 (HY000): You must reset your password using alter user statement before executing this statement.

Change password: set password = password ('1970 @ Zxc ');

Or:

Copy codeThe Code is as follows:
Alter user 'root' @ 'localhost' identified by '2017 @ Zxc ';

Execution successful again.

We learned from the official documentation that the password can be changed using the alter user statement. After logging on to MySQL, run the following statement:

Copy codeThe Code is as follows:
Alter user 'root' @ 'localhost' identified by '2017 @ Zxc ';

Change the password of the root account to 123 @ Zxc.

MySQL has enhanced the security of user passwords. Therefore, the password must contain numbers, upper-case letters, lower-case letters, and special characters. If the password you set is too simple, you will be prompted:

ERROR 1819 (HY000): Your password does NOT satisfy the CURRENT policy requirements.

The above section describes how to install MySQL database using MySQL yum source. I hope it will help you. If you have any questions, please leave a message, the editor will reply to you in a timely manner. Thank you very much for your support for the help House website!

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.