Wordpress local raspbian installation : MySQL crashes once a minute - mysql

I've found many similar posts, however I wasn't able to find out a solution, so here is my question.
I've been running since more than one month a local wprdpress installation on Raspbian.
Since yesterday, I always get an error while attempting to tonnect to the website (WP debug mode is ON) :
Warning: mysqli_real_connect(): (HY000/2003): Can't connect to MySQL server on '127.0.0.1' (111) in /var/www/html/wp-includes/wp-db.php on line 1488
Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /var/www/html/wp-includes/wp-db.php on line 1518
Warning: mysql_connect(): Can't connect to MySQL server on '127.0.0.1' (111) in /var/www/html/wp-includes/wp-db.php on line 1518
Trying to know more using the command : mysqladmin -u root -p status
gives me :
mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)'
Check that mysqld is running and that the socket: '/var/run/mysqld/mysqld.sock' exists!
I chmoded the folders involved to 755. I don't use localhost to name my DB (in wp-config.php, in my.cnf) but 127.0.0.1.
If I restart the MySQL service, it works for more or less one minute, then stops again. Using safe-mode didn't work either.
I think this is a socket problem but how can I solve it ?

Related

Nothing will connect to mysql on localhost

I've tried just about everything I can find online. I'm going to try to make a complete list of all of the things that I have tried in no particular order (as it's been about two weeks of hunting for solutions). Where it all starts is my formerly functioning local dev setup was working fine aside from some SQL settings that were interfering with my already established codebase. I found resources online that detailed editing my.cnf file; which I did. From that point forward, nothing will connect to mysql.
1. Uninstall and remove mysql files via terminal
2. Reinstalled mysql and attempted to connect via terminal, didn't work
Running via terminal: mysql -u root
Resulting socket error: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
3. Connected to services via DBngin
All services start up and seem to run fine; (Homebrew svcs: php, mysql, httpd). All show a green light and appear to be functioning.
4. Attempt to connect to mySQL via TablePlus
These settings worked before I messed with my.cnf file as described initially (no password):
Host: 127.0.0.1
Port: 3306
User: root
Resulting error: Can't connect to MySQL server on '127.0.0.1' (61)
5. Installed MySQL Workbench / Server, won't connect
Resulting error: SQLSTATE[HY000] [2002] Connection refused
6. Any attempt to load localhost:3306 in Chrome/Safari/Firefox all result in the following
SQLSTATE[HY000] [2002] Connection refused
7. See if mySQL is running
Run in terminal: ps aux |grep mysql
Results in: natashya 74640 0.0 0.0 34132100 908 s002 S+ 1:40pm 0:00.00 grep mysql
Try to kill via: kill 74640
Results in: kill: kill 74640 failed: no such process
Run: brew services restart mysql
Results in: ==> Successfully stopped `mysql` (label: homebrew.mxcl.mysql) ==> Successfully started `mysql` (label: homebrew.mxcl.mysql)
Contents of my.cnf
# Default Homebrew MySQL server config
# Only allow connections from localhost
[mysqld]
bind-address = 127.0.0.1
mysqlx-bind-address = 127.0.0.1
port = 3306
mysqlx-port = 33060
socket = /var/lib/mysql/mysql.sock
datadir = /usr/local/mysql
tmpdir = /tmp
mysqlx=OFF
[client]
port = 3306
socket = /var/lib/mysql/mysql.sock
Thank you so much to Bill Karwin for help. I am however still unable to resolve the site I'm attempting to access (localhost:9000) and get this error: SQLSTATE[HY000] [2002] Connection refused
Redux of the comment thread above:
Check the MySQL Server error log for clues.
The log indicated the directory for the socket files, /var/lib/mysql, did not exist.
Once the directory was created with the right permissions, the MySQL Server process created the socket file.
Also:
ps aux | grep mysql matches the process running grep mysql because the word 'mysql' appears in that command.

WHM/ MySQL "Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (111)"

After resizing the server at DigitalOcean, MySQL no longer works. I restarted MySQL. Upgraded MySQL. Restarted WHM. Nothing works. I think it has to do with mysql.sock. But I tried every solution on stackoverflow. Still doesn't work. Would you mind taking a look?
[root#ns ~]# mysqladmin -u root -p status
mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (111)'
Check that mysqld is running and that the socket: '/var/lib/mysql/mysql.sock' exists!
Screenshot Terminal error
Screenshot phpMySQL error
In order to trace the issue, we would need some more information, please post the output from your MySQL log .

Unable to start MySQL

I am using a virtual machine (ubuntu12.04) with Vagrant for development purposes. I had installed Apache, PHP and MySQL - which all originally worked. Now, MySQL seems to not work.
When I check the stasus by using sudo service mysql status:
mysql stop/waiting.
I tried to restart MySQL:
stop: Unknown instance
start: Job failed to start
While trying to connect via mysql -u root -p:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket
'/var/run/mysqld/mysqld.sock' (111)
I have gone through different questions related to this issue on this site but most solutions are referring to a memory space problem (which is not in my case).

Fix configuration problems with MacPorts MySQL

I have mysql/mysqli installed on my local machine via MacPorts and can access mysql/mysqli commands from the command line ONLY when using locahost.
If I try running:
mysql -u root -h 127.0.0.1 -p
I get the following error:
ERROR 2003 (HY000): Can't connect to MySQL server on '127.0.0.1' (61)
When running:
mysql -u root -h localhost -p
Everything is fine.
The reason this bothers me is that I am trying to use mysqli_connect in a PHP script running on localhost. When I enter the host as localhost, it gives me this error:
Warning: mysqli_connect(): (HY000/2002): No such file or directory in ... on line 2
bool(false) Failed to connect to MySQL: No such file or directory
And when I enter the host as 127.0.0.1, I get a different error:
Warning: mysqli_connect(): (HY000/2002): Connection refused in /Users/raph/coding/webroot/rugapp/qbo-palmer/docs/partner_platform/example_app_ipp_v3/test.php on line 2
bool(false) Failed to connect to MySQL: Connection refused
It seems as though I have some configuration problems. What is the best way to fix them?
The connection to localhost uses a unix socket. It seems the correct socket path is built into the mysql binary you use, which explains why it works on the command line. For the unix socket connection to work from PHP, you need to specify MacPorts MySQL's non-standard socket path as you would normally specify a port number.
For the failure to connect using 127.0.0.1 (which forces IPv4 and avoids the unix socket), see mysql running but cannot connect to 127.0.0.1.

Problems connecting to mysql on debian, error 2002

I'm trying to run a mysql connection, and I am getting this error:
ERROR: Unable to connect to mysql: (2002) Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
I have been checking on other forums etc, and yes i checked if mysql server is running, and yes it is running ok,no portblocking, but what i see strage is that i dont ahve mysql.sock in my /var/lib/mysql directory.
I appreciate any sign of help.