mysql.sock function - solve the problem that mysql.sock cannot be found directly - regenerate mysql.sock

=

=

=

mysql.sock function - solve the problem that mysql.sock cannot be found directly - regenerate mysql.sock

 

mysql.sock role

There are two ways to connect mysql: 
1. Connection through TCP/IP 
2. Connection through local socket. For mysql.sock, its function is that the program and mysqlserver are on the same machine and are available when a local connection is initiated. When connecting, you do not need to define the specific IP of the connection host, as long as it is empty or localhost.

 

Solve the problem that mysql.sock cannot be found directly

The problem of Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock appeared. 

The online method is to check the /etc/my.cnf file, check the location of mysql.sock, and then establish a soft connection to connect the found location of mysql.sock with the location mentioned in the configuration file.

 

Regenerate mysql.sock

The problem I encountered is that I can't find it directly! ! ! ! ! A full search through the find command can't find it either.

So I found another article, http://www.weiruoyu.cn/?p=673  , but the article mentioned that there is no switching user, it doesn't matter, I have been using the root user, and then, according to the above of:

$/usr/bin/mysql_install_db     //重建授权表

$/usr/bin/mysqld_safe &

$/usr/local/bin/mysql                //测试

mysq>bye;
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

Re-establish a new authorization table, regenerate new /var/lib/mysql/mysql.sock and hostname.pid, then log in directly through the mysql command, and change the password:

mysql> use mysql;
mysql> update user set password=password("你的新密码") where user="root";
mysql> flush privileges;
mysql> quit
  • 1
  • 2
  • 3
  • 4

Just restart the service and you're done! ! ! ! !

 

=

=

=

 

Guess you like

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