没有不值得去解决的问题,也没有不值得去学习的技术!

Troubleshooting the MySQL Error: Can’t Connect to /var/lib/mysql/mysql.sock (2)

作者:

在

,

1. Opened the website backend URL, and received an error: Unable to connect to database: Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’ (2)

2. To fix the MySQL connection error, I checked the configuration file of the ISC framework (Interspire Shopping Cart, a legacy e-commerce system) and confirmed that it connects to the local database. See Figure 1.

To fix the MySQL connection error, I checked the configuration file of the ISC framework (Interspire Shopping Cart, a legacy e-commerce system) and confirmed that it connects to the local database.

3. I then checked the MySQL status (to confirm whether it started successfully) and found that it had stopped. Starting MySQL failed.

Plaintext

[root@li1269-60 jfc]# service mysqld status                                     |
mysqld is stopped
[root@li1269-60 jfc]# service mysqld start

Timeout error occurred trying to start MySQL Daemon.
Starting mysqld:  [FAILED]
[root@li1269-60 jfc]#


4. I reviewed the key logs for the MySQL startup failure (the most critical troubleshooting command). Based on the MySQL log snippet provided, the core error is that Table ‘./jammerfromchina/cart_prodd’ is corrupted — this is the root cause of the MySQL startup timeout / failure (a corrupted table prevents the InnoDB/MyISAM engine from loading, causing the MySQL startup process to hang).

Plaintext

[root@li1269-60 jfc]# grep -i "error|fail|timeout" /var/log/mysqld.log
130419  7:01:24 [ERROR] /usr/libexec/mysqld: Table './jammerfromchina/cart_prodd
130419  7:01:24 [ERROR] /usr/libexec/mysqld: Table './jammerfromchina/cart_prodd
130419  7:01:24 [ERROR] /usr/libexec/mysqld: Table './jammerfromchina/cart_prodd
130419  7:01:24 [ERROR] /usr/libexec/mysqld: Table './jammerfromchina/cart_prodd
130419  7:01:24 [ERROR] /usr/libexec/mysqld: Table './jammerfromchina/cart_prodd
130419  7:01:24 [ERROR] /usr/libexec/mysqld: Table './jammerfromchina/cart_prodd
130419  7:01:24 [ERROR] /usr/libexec/mysqld: Table './jammerfromchina/cart_prodd
130419  7:01:24 [ERROR] /usr/libexec/mysqld: Table './jammerfromchina/cart_prodd
130419  7:01:24 [ERROR] /usr/libexec/mysqld: Table './jammerfromchina/cart_prodd
130419  7:01:24 [ERROR] /usr/libexec/mysqld: Table './jammerfromchina/cart_prodd
130419  7:01:24 [ERROR] /usr/libexec/mysqld: Table './jammerfromchina/cart_prodd
130419  7:01:24 [ERROR] /usr/libexec/mysqld: Table './jammerfromchina/cart_prodd
130419  7:01:24 [ERROR] /usr/libexec/mysqld: Table './jammerfromchina/cart_prodd
130419  7:01:24 [ERROR] /usr/libexec/mysqld: Table './jammerfromchina/cart_prodd
130419  7:01:24 [ERROR] /usr/libexec/mysqld: Table './jammerfromchina/cart_prodd
130419  7:01:24 [ERROR] /usr/libexec/mysqld: Table './jammerfromchina/cart_prodd
130419  7:01:24 [ERROR] /usr/libexec/mysqld: Table './jammerfromchina/cart_prodd
130419  7:01:24 [ERROR] /usr/libexec/mysqld: Table './jammerfromchina/cart_prodd
130419  7:01:24 [ERROR] /usr/libexec/mysqld: Table './jammerfromchina/cart_prodd
130419  7:01:24 [ERROR] /usr/libexec/mysqld: Table './jammerfromchina/cart_prodd
130419  7:01:24 [ERROR] /usr/libexec/mysqld: Table './jammerfromchina/cart_prodd
130419  7:01:24 [ERROR] /usr/libexec/mysqld: Table './jammerfromc^C[ 3502.924666


5. Confirming whether disk resources are sufficient is a critical prerequisite for troubleshooting the current issue (a full disk is one of the core causes of MySQL startup failures and table corruption). Final confirmation: the disk is 100% full (the root partition /dev/sda has exhausted its 78G). See Figure 2.

Confirming whether disk resources are sufficient is a critical prerequisite for troubleshooting the current issue (a full disk is one of the core causes of MySQL startup failures and table corruption). Final confirmation: the disk is 100% full (the root partition /dev/sda has exhausted its 78G)
Plaintext

[root@li1269-60 jfc]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda               78G   78G     0 100% /
tmpfs                 1.9G  116K  1.9G   1% /dev/shm


6. I noticed that the Linode instance could now be resized. The current Linode plan has 4 GB of RAM and 80 GB of storage. It can be resized to a Linode plan with 8 GB of RAM and 160 GB of storage. Reference: Troubleshooting analysis of a failed Linode instance configuration upgrade, upgrading the configuration to 160GB.

7. I checked the disk usage again and confirmed it met expectations.

Plaintext

[root@li1269-60 ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda              148G   78G   68G  54% /
tmpfs                 3.9G  116K  3.9G   1% /dev/shm
[root@li1269-60 ~]#


8. Now, upon opening the backend, there are no more errors. I can log in normally. See Figure 3.

Now, upon opening the backend, there are no more errors. I can log in normally

关于作者 · 持续学习与技术实践

我是一名拥有 15 年以上开发经验的技术从业者,自 2013 年起持续运营个人技术博客,记录工作与个人项目中遇到的真实问题,以及解决问题过程中的探索、实践和思考。

除了技术写作,我也在持续开发和维护自己的独立项目,探索新技术和新工具在实际场景中的应用。我始终相信,没有不值得去解决的问题,也没有不值得去学习的技术。

如果这篇文章对你有所帮助,欢迎浏览博客中的其他文章,也欢迎交流技术经验与想法。

关于我  ·  GitHub  ·  邮件联系