Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to avoid errors during mysql startup and analysis of the function of sock files

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article analyzes "how to avoid mysql startup errors and sock file function analysis". The content is detailed and easy to understand, "how to avoid mysql startup errors and the role of sock file analysis" interested friends can follow the editor's ideas slowly in-depth to read, I hope that after reading can be helpful to everyone. Let's follow the editor to learn more about "how to avoid mysql startup errors and the function analysis of sock files".

The following errors are sometimes encountered during the startup of mysql

Can't connect to local MySQL server through socket'/ tmp/mysql.sock' (2)

What is the purpose of the mysql.sock file?

How to avoid such a mistake?

Answer 1.

This mysql.sock should use unix domain socket as the carrier of the communication protocol when the host and client of mysql are on the same host (physical server). It is faster than tcp. Usually the reason for this problem is that your mysql server is not running.

Check to see if your / tmp/mysql.sock file exists? Normally, it's supposed to be there.

Or use netstat to see if there is any in the results.

Active UNIX domain sockets

Answer 2.

This file is used for socket connections.

That is, this file exists only when your daemon starts.

But your mysql program (this program is client-side, server-side mysqld) can choose whether or not to use mysql.sock files to connect (because this method is only suitable for connecting local mysqld on Unix hosts), for any type of host that is not local. These are described in the MySQL manual (including the Chinese version of Yanzi's translation, which covers version 3.23). Just look at it and you'll see.

The previous friend said that he could not connect, but the most likely reason is that the daemon of mysqld has not been started.

Answer 3.

There are two ways to connect to Mysql:

(1) TCP/IP

(2) socket

For mysql.sock, the function is that the mysql client program mysql and the mysql server program mysqlserver are on the same machine and are available when initiating a local connection.

For example, you do not need to define the specific IP to connect to host, as long as it is empty or localhost.

In this case, it is possible to connect properly even if you change the external port of the mysql.

Because after you change the port in my.ini or my.cnf, mysql.sock is generated with each mysql server startup. It has been regenerated according to the time you restart mysql after you have changed my.cnf, and the information has changed accordingly.

Then for external connections, you must change the port to connect.

Cannot find the processing method of mysql.sock

The following message appears:

Got an error: Connection error: Can't connect to local MySQL server through

Socket'/ var/lib/mysql/mysql.sock'

The sudden disappearance of mysql.sock is a common problem.

If the runtime appears after installing MySQL for the first time, just find out where mysql.sock is.

The above information indicates

Mysql.sock should be under / var/lib/mysql/.

If you don't find it, just...

# locate mysql.sock

It'll come out, and then you can

# mysqladmin-S / path / mysql.sock-u root

What if it is normal and suddenly one day the system tells you that you can't find the damn file mysql.sock?

Then you have to restart the service with / etc/rc.d/init.d/mysql restart or service mysql restart.

If it doesn't work, go first.

# ps-aux | grep mysql's process of finding mysql.

# kill mysql process number to determine all Killer light

Restart the service again / etc/rc.d/init.d/mysql restart or service mysql restart

On how to avoid mysql startup errors and the role of sock file analysis is shared here, I hope that the above content can make you improve. If you want to learn more knowledge, please pay more attention to the editor's updates. Thank you for following the website!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report