0

I've developed a website on the Silverstripe framework and deployed this to a digital ocean server using centos (7.0.1406) , mariadb (10.0.14) and apache (2.4.6). I'm somewhat of a novice when it comes to system admin so set up the server following instructions in the digital ocean community docs (https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mysql-php-lamp-stack-on-centos-7).

I'm randomly getting the following error when I try to connect to the site:

[Warning] mysqli::mysqli(): (HY000/2002): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (111)

On

$this->dbConn = new MySQLi($parameters['server'], $parameters['username'], $parameters['password']); 

When this occurs, I reboot the server (with 'reboot') the issue goes away. It only seems to occur with activity is happening in the CMS. My client has experienced it a number of times when trying to upload images and I have just seen it for the first time when switching pages in the CMS.

No amount of use on the front end of the website causes issues (so far at least). What could be causing this issue? Are there any actions which can be performed by a website (PHP) that could trigger this failure? Overuse of system resources/hang ups somewhere/timeouts? Where can I start my debugging process?

I've deployed numerous sites under similar environments in the past but have never encountered this except for forcing a shut down via the digital ocean control panel.

5 Answers 5

3

111 means Connection refused. That is, nothing is listening to that socket.

This means that MariaDB is not running, or was configured to listen to some other socket (or none at all).

Check your MariaDB configuration to ensure you specified the socket correctly, then restart it.

2
  • We are assuming that the client program is configured for a local file socket, and not the loopback interface. Fraser needs to post more of the configuration, specifically, what is in $parameters['server'] Commented Nov 26, 2014 at 19:23
  • Hi @AveryPayne . Thanks for taking the time to read the post. $paramaters['server'] is 'localhost'. Cheers Commented Nov 27, 2014 at 9:33
2

I had the same problem and found out a few things after digging around. MariaDB is a drop-in replacement for mysql. On the new system, mysql is the MariaDB client (although I'm not clear on what that means). Checking to see if the service was running:

service mysqld status 

which indicated:

Redirecting to /bin/systemctl status mysqld.service

mysqld.service

Loaded: not-found (Reason: No such file or directory)

Active: inactive (dead)

In other words, the mysqld service is not running.

Starting the service worked for me:
systemctl start mariadb.service 

Now all the mysql commands work as expected.

To tie the last knot, enable the service at boot:
systemctl enable mariadb.service 
0
1

Hi @AveryPayne . Thanks for taking the time to read the post. $paramaters['server'] is 'localhost'. Cheers – Fraser

The short version is, You Can't Get There From Here.

Based on this comment, and the error message, I'd say you have a problem with the type of connection. The socket in the error message is stated as /var/lib/mysql/mysql.sock but you are attempting a network connect via localhost, which maps to the network address 127.0.0.1. Your program looks like it isn't using the correct parameter at runtime. Double-check that the parameter really is 'localhost' at runtime by having it log/write out the parameter somewhere, and double-check that MySQL is attached to network port 3306, instead of a file socket at /var/lib/mysql/mysql.sock.

Alternatively, change the parameter for the program and MySQL to use the file socket instead. Whatever works easiest.

0

The first step would be to look into the logfile of Mariadb, which is typically located in /var/lib/mysql and named *.err.

You could also verify that Mariadb is still running on the server when you get this error message and you could verify if you are still able to log in (in case it is running).

2
  • Thanks. I've just had a look for a log file. There was nothing in /var/lib/mysql with a .err extension, but there is an aria_log.0000001, ib_logfile0 and ib_logfile1 all of those just contain (what appear to be) broken or missing characters Commented Nov 26, 2014 at 15:57
  • 2
    You need to check the logging settings in your configuration file. Commented Nov 26, 2014 at 16:48
0

Hi check whether your disk is full in the installation partition. And if the storage exists manage the logs in the Mariadb server adding following lines to my.conf

expire_logs_days = 10 #this is for managing the log days max_binlog_size = 100M #this is for managing the log size 

Move the logs to a directory and restart the mariadb server.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.