Linux open and close mysql remote

       In many cases, the mysql root password will be forgotten or lost. Let me sort out the solutions, hoping to help friends who are new to Linux.  

1. Modify my.cnf 
             to add skip-grant-tables



   2. Find the mysql bin file /usr/bin

     ./mysqladmin -uroot password 'admin888'

  3. Set up remote connection

   mysql -u root -p
           grant all on *.* to 'root'@'%' identified by 'admin888';

  (Just for testing, you can actually turn it off)

    Use the client (client software such as phpadmin) to connect to the database remotely to view, the migrated database is not restored.

    4. Login with new password and change password



 

    mysql -uroot -p

    select user,password,host from mysql.user;
            update user set password=password("密码") where user='root';

    flush privileges;

   5. Close the remote connection

    I believe that after this step, everyone has already set it up.

     Modify my.cnf to delete skip-grant-tables 

     Log in to mysql and set the remote user to close

             update user set host = '%' where user = 'root'; 

              select host, user from user;

     Try connecting to the machine with a new password. The password has been changed.

Guess you like

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