Installation and remote connection configuration of Mysql 5.7 under Linux

  I remember I wrote a blog about installing mysql under Linux and its common problems and configuration, but I encountered many problems when installing mysql on a cloud host in the past two days, in order to facilitate my future reference and not to let latecomers Falling into the same pit and wasting too much time, I took the time to organize and record the problems I encountered during the actual installation and configuration process, hoping to help myself or others in the future.

 

  The situation is like this. The previous development environment, mysql database, was built on the intranet environment. The database version was 5.5. Later, some failures occurred, which led to the need to migrate the database to the cloud host. At first, a mysql database was installed with yum for simplicity and convenience. The result is When importing data, it was found that the "function" (stored procedure) was not imported successfully. Checking the current database installation version of the cloud host, it was found to be 5.1, which should be caused by the import of a higher version of the database to a lower version. So I can only uninstall the low version of mysql installed by this yum first.

 

1. Steps to uninstall mysql:

 

(1)service mysqld status
(2)service mysqld stop
(3)rpm -qa|grep -i mysql
(4)rpm -e --nodeps MySQL-server-5.1.22-0
(5)whereis mysql
(6)find / -name mysql
(7) rm -f /etc/my.cnf
(8)rm -rf /var/lib/mysql

  

2. Upload a mysql installation package (version mysql-5.7.11-1.el6.x86_64.rpm-bundle.tar) and decompress it

 

tar -zxvf mysql-5.7.11-1.el6.x86_64.rpm-bundle.tar

  

3. After decompression, there may be about ten rpm installation packages, but we only need four of them. The installation package name is as follows:

 

mysql-community-common-5.7.11-1.el6.x86_64
mysql-community-libs-5.7.11-1.el6.x86_64
mysql-community-client-5.7.11-1.el6.x86_64
mysql-community-server-5.7.11-1.el6.x86_64

  

4. Execute the following commands in sequence to install

 

rpm -ivh mysql-community-common-5.7.11-1.el6.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.11-1.el6.x86_64.rpm
rpm -ivh mysql-community-client-5.7.11-1.el6.x86_64.rpm
rpm -ivh mysql-community-server-5.7.11-1.el6.x86_64.rpm

  

5. After the installation is completed, the root user of the previous lower version of the database can go in and change the initial password through a verification-free method, but the database of this version must be entered through a password in order to improve the security mechanism, so it is necessary to find its initial password first. Its initial password is a random password, which can be found in the log. The specific operation steps are as follows:

 

(1) vi /etc/my.cnf view log-error=/var/log/mysqld.log
(2) Search the log for the keyword A temporary password is
(3) After the keyword is the random password of the initial root user of the database

  

6. Enter the database according to the initial password. After entering the database, you must reset the root user password before operating the database. The specific operation steps are as follows:

 

(1)mysql -uroot -paKOj9-QwCmix
(2)set password = password('aQjy9-QwCmix');
(3)alter user 'root'@'localhost' password expire never;
(4)flush privileges;

 

7. After the installation of this database is completed, if you want to add a user for its remote connection to access and operate a database, the operation steps are as follows:

 

(1)create user myt identified by 'password';
(2)grant select,insert,update,delete on *.* to myt@"%" identified by "password"; # 授权
(3)select user, host, authentication_string from user;

  

+----------- +-----------+-------------------------------------------------------------------------+

| user         | host       | authentication_string                                                          |

+----------- +-----------+-------------------------------------------------------------------------+

| root       | localhost | *5D3B0C84FC999AD66714CB2D85D9E0F9D2BDCDBF |

| mysql.sys| localhost | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE |

| myt | % | *3B9EA1ADC939A8F4AB4DDF3AC2324B4B4A29C816 |

+------------+-----------+-------------------------------------------------------------------------+

 

8. In this way, you can connect and access remotely through the Navicat For Mysql connection tool.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326988448&siteId=291194637