Solve MySQL error 2002 (HY000)

Error 2002 (HY000): can’t connect to local MySQL server through socket ‘/ var/run/mysqld/ mysqld.sock ’ (2)

When starting mysql, it appears:

because I haven’t used MySQL under Ubuntu for a long time, I thought my password was wrong, and I repeatedly lost it several times. I found that it’s still like this. I also checked the related blogs on the Internet and found that it can’t work. Generally, this kind of error appears on the Internet, which is a bit similar to

In fact, it’s not the same. Pay attention to distinguish the following folders, so go to the configuration file of Mysql to see where the socket folder is, and the configuration file of MySQL is in
/etc/MySQL/ my.cnf In this, cat has a look:

found this sentence remember to edit So when you install mysql, the MySQL Server package is not installed (I don’t know how to get in before, ha ha), so you can install this package

you can also check whether there is this package first

so after installing mysql-server-5.7, you can enter the root password.
A289885427
now my.cnf There is no previous sentence

Read More: