Recently I encounter a wired problem, which is I cannot connect to the mysql server with mysql client on the server, but the application can connect. I finally find the solution to solve the problem, but still don’t know the cause of the proelbm.
Solution
The solution is start a new terminal to connect the server.
I accidentally start a new terminal and connect to the server and try to connect the mysql server with root user, and I can connect to it.
I also tried some other solutions, in on of my server, I stoped the mysql server, and start the server with --skip-grant-tables
option, and modified the database with root user.
sudo mysqld_safe --skip-grant-tables
But on another server, I can’t start mysql server with the above command, I think the cause of the problem might be the setting of the terminal?
After I start a new terminal and connect to both of my servers, and I can connect to the mysql server successfully.
If you encountered the same problem, you can try this solution.