[Osaka/Yokohama/Tokushima] Looking for infrastructure/server side engineers!

[Osaka/Yokohama/Tokushima] Looking for infrastructure/server side engineers!

[Deployed by over 500 companies] AWS construction, operation, maintenance, and monitoring services

[Deployed by over 500 companies] AWS construction, operation, maintenance, and monitoring services

[Successor to CentOS] AlmaLinux OS server construction/migration service

[Successor to CentOS] AlmaLinux OS server construction/migration service

[For WordPress only] Cloud server “Web Speed”

[For WordPress only] Cloud server “Web Speed”

[Cheap] Website security automatic diagnosis “Quick Scanner”

[Cheap] Website security automatic diagnosis “Quick Scanner”

[Reservation system development] EDISONE customization development service

[Reservation system development] EDISONE customization development service

[Registration of 100 URLs is 0 yen] Website monitoring service “Appmill”

[Registration of 100 URLs is 0 yen] Website monitoring service “Appmill”

[Compatible with over 200 countries] Global eSIM “Beyond SIM”

[Compatible with over 200 countries] Global eSIM “Beyond SIM”

[If you are traveling, business trip, or stationed in China] Chinese SIM service “Choco SIM”

[If you are traveling, business trip, or stationed in China] Chinese SIM service “Choco SIM”

[Global exclusive service] Beyond's MSP in North America and China

[Global exclusive service] Beyond's MSP in North America and China

[YouTube] Beyond official channel “Biyomaru Channel”

[YouTube] Beyond official channel “Biyomaru Channel”

[2002] Three causes and solutions for MySQL socket errors

When connecting to MySQL server from MySQL client software (mysql, PHP, Perl, etc.),

  • socket '/tmp/mysql.sock '
  • No such file or directory (trying to connect via unix : ///tmp/mysql . sock)

You may be unable to connect due to an error like this.

This means
"Unable to connect to local MySQL server through socket /tmp/mysql.sock." (I just translated it)

A socket is a Unix domain socket (file system socket) that
communicates between the server and client through input/output of this file when communicating within the local system.
He's the intermediary.

Now, I would like to explain the causes of such errors and how to deal with them.

Cause of the error

Cause 1. MySQL server is not started

$ ps aux | grep mysqld

Check if the process exists.
If not, start it.

$ sudo /etc/init.d/mysqld status 

Cause 2. The paths of the Unix socket used by the MySQL server and the Unix socket used by the client software are different.

No such file or directory (trying to connect via unix:///tmp/mysql.sock)

For example, the above error shows that the client is referring to /tmp/mysql.sock, but
the MySQL server is referring to /var/lib/mysql/mysql.sock.

There are two solutions in this case.

Solution A. Align clients

Referring to the MySQL configuration file, /etc/my.cnf,

[mysqld] socket=/var/lib/mysql/mysql.sock

Since the path is written like this, all you need to do is set the socket of the client software to the same path.

Solution B. Match MySQL

Let's rewrite /etc/my.cnf as shown below.

[mysqld] socket=same socket path as client [client] soket=same socket path as client [shell] After rewriting, restart MySQL. [shell]$ sudo /etc/init.d/mysqld restart

Cause 3. There is no socket file in the first place.

There are two ways to solve this too.

Solution A. Restart the MySQL server and it will be restored.

(*Restart the server, not mysql.)

$ sudo shutdown -r now

Solution B. Create a socket file

After checking /etc/my.cnf and checking the path,

$ touch /path/mysql.sock $ chown mysql:mysql /path/mysql.sock

Create a socket at that path and restart MySQL.

$ sudo /etc/init.d/mysql restart

These are the causes and solutions for MySQL 2002 errors.

Introducing our Beyond

Since its founding, Beyond has developed technology as a multi-cloud integrator and managed service provider (MSP) and has designed, constructed and migrated using a variety of cloud/server platforms, including AWS, GCP, Azure, and Oracle Cloud.

We provide custom-made cloud/server environments that are optimized for customers according to the specifications and functions of the systems and applications they require, so if you are interested in the cloud, please feel free to contact us. .

● Cloud/server design/construction
● Cloud/server migration/migration
● Cloud/server operation, maintenance, and monitoring (24 hours a day, 365 days a year)

If you found this article helpful , please give it a like!
4
Loading...
4 votes, average: 1.00 / 14
57,523
X facebook Hatena Bookmark pocket
[Webinar] Introduction to Multi-Cloud: Which cloud is best for your business? Get the latest information on the 8 major clouds!

[Webinar] Introduction to Multi-Cloud: Which cloud is best for your business? Get the latest information on the 8 major clouds!

[Webinar] From the operational structure to specific steps! A complete overview of cloud server operation and maintenance

[Webinar] From the operational structure to specific steps! A complete overview of cloud server operation and maintenance

The person who wrote this article

About the author