The root password problem encountered when installing mysql on ubuntu18

       Recently, I bought a new windows laptop and installed the ubuntu system, and then the tragedy happened.

       Install mysql with the command, the default is 5.7 (the lower version cannot be installed with the command), then mysql -u root -p (then enter the password) can not connect, sudo mysql -u root -p (then enter the password, in fact Enter any password) to connect. The result is that the management tool (workbench) cannot be connected, and the project cannot be started. After a whole day of Baidu, I finally encountered a buddy who had the same phenomenon as me, and then seriously said that after reinstalling mysql, I can connect without sudo. I have reinstalled it n times, but it still doesn't work. I even suspected that it was a system problem, and I was going to reinstall ubuntu16. Fortunately, I saw a buddy on the Internet and said that 16 is also installed by default with 5.7. Then fell into contemplation. . . .

       Continue to Baidu, Nima, the sun appeared, a buddy said that after 5.7, the root user added the auth_socket plug-in, and the local connection is not allowed. Then use sudo to enter mysql and query select * from mysql.user. I found that there are several users in it. I saw the difference between the plugin field and the authentication_string (the column of the root user password is empty), and I seem to understand a little (in fact, I don't fully understand it), and suddenly remembered that the Internet said to use /etc/mysql/debian.cnf I suddenly felt that debian-sys-maint was the user I was looking for, and of course I could create a new one (root was used locally before), it was a waste of time, and I learned a lesson.

Guess you like

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