Yum source for installing and configuring MySQL
# install MySQL yum source, below is the RHEL6 series mysql5.6 download Address:
wget http://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm
Below is the download address for 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 a few commands you can learn by the way
Copy Code code as follows:
# 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
The version of this installation is 5.7.14, the test environment originally has 5.1.73 version, is the upgrade installation.
Yum install MySQL
Third, initialize and start MySQL
Service mysqld Start
The direct start service will have an error, as follows:
[root@localhost lib]# Service mysqld start
MySQL Daemon failed to start.
Starting mysqld: [Failed]
WORKAROUND: The new version requires MySQL to be initialized first.
Initializing MySQL
Copy Code code as follows:
# mysqld--initialize--user=mysql--datadir=/var/lib/mysql
Or
Copy Code code as follows:
# mysqld--initialize-insecure--user=mysql--datadir=/var/lib/mysql
In addition, when you log in as a MySQL account and execute the program, you can remove the--user option from the command.
Through the official documentation we can tell if I am logged on to the Linux system as root, you can perform: mysqld--initialize--user=mysql or mysqld--initialize-insecure--user=mysql. If I am logged on to the Linux system as a MySQL user, I can perform: mysqld--initialize or Mysqld--initialize-insecure.
On any platform, the--initialize option is installed in "Default security mode" (that is, the generation of a random root initial password). In this case, the password is flagged 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 a password for your account in a timely manner before the server is put into production.
Using--initialize will generate a random initial password for the root account, we can use the command: Mysql-u root-p, and then enter a 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 login directly to MySQL.
I encountered the following error during initialization:
[ERROR]--initialize specified but the data directory has files in it. Aborting.
[ERROR] Aborting
Workaround:
Copy Code code as follows:
Reason Analysis:
The MYSQLD service checks whether 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, a file or a 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 directory, try again.
All in all: Before initialization, first check the existence of the data directory, 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, it's OK.
Execute the initialization command again and execute successfully.
[Note] A temporary password is generated for root@localhost:ihey0gfhtt;f
Remember to initialize the generated temporary root password, which is used when logging in
Start Service mysqld start immediately after initialization is complete
Four, connect MySQL and modify password
When initialized, a temporary root password is generated, and the password must be changed before the command can be executed.
Copy Code code as follows:
Mysql-uroot-p Temporary password
After login, if the password is not changed immediately, execute the command times the following error:
mysql> show databases;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before the this executing.
Modify Password: Set Password=password (' 123@zxc ');
Or:
Copy Code code as follows:
Alter user ' root ' @ ' localhost ' identified by ' 123@zxc ';
Successful execution again.
We learned from the official documentation that you can modify the password with the ALTER USER statement. After you log in to MySQL, execute the statement:
Copy Code code as follows:
Alter user ' root ' @ ' localhost ' identified by ' 123@zxc ';
Change the password on the root account to 123@ZXC.
MySQL security of the user password has been enhanced, so the password must be set contains numbers, uppercase letters, lowercase letters, special symbols, if you set the password is too simple, will prompt:
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements.
The above is a small series to introduce the use of MySQL yum source to install MySQL5.7 database method, I hope to help you, if you have any questions please give me a message, small series will promptly reply to everyone. Here also thank you very much for the cloud Habitat Community website support!