Centos7 install mysql5.7

1. Go to the mysql official website to get the download link of mysql

   https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm



 

2. Download the mysql rpm package

wget https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm

 

3.rpm installation

rpm -ivh mysql57-community-release-el7-11.noarch.rpm

 

4. After the rpm installation is complete, yum installation

yum install mysql57-community-release-el7-11.noarch.rpm

 

5. View the initial password after the installation is complete

grep temporary password /var/log/mysqld.log

 

6. Test login

mysql -uroot -p

 

7. If you can't do anything after logging in or log in with a 1045 error code, try to change the password and log in again

   $ sudo systemctl stop mysqld.service

     $ sudo systemctl set-environment MYSQLD_OPTS="--user=mysql --skip-grant-tables --skip-networking"
     $ sudo systemctl start mysqld.service    
     $ mysql -u root mysql
 
     mysql > UPDATE mysql.user SET authentication_string=PASSWORD("abcdef")  WHERE user='root' and host='localhost';
     mysql > flush privileges;
     mysql > quit
 
     $ sudo systemctl unset-environment MYSQLD_OPTS
     $ sudo systemctl restart mysqld.service

 

 mysql open remote connection

1. Log in to the database

mysql -uroot -p

 

 2. Open the remote connection

    root username
    % everyone can access
    password password

mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;
mysql> FLUSH PRIVILEGES;

 

 3. Restart mysql

service mysqld restart

 

 If you still cannot connect to mysql remotely after performing the above steps, try to open port 3306 of the firewall or close the firewall

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326197398&siteId=291194637