Digital ocean sql connection and phpmyadmin suddenly stopped working - mysql

I have a Laravel app on digital ocean and it runned fine for about 4 days now.
But today when I woke up it suddenly couldn't connect to the DB.
Also when I try to login in phpmyadmin it says
2002 - Connection refused — The server is not responding (or the local server's socket is not correctly configured).
I tried changing localhost to 127.0.0.1 in the config-db.php file and restarting apache, because some guy in their forums had the same problem and said that it fixed it for him, but for me it had no effect.
Other errors I see are
mysqli_real_connect(): (HY000/2002): Connection refused
Connection for controluser as defined in your configuration failed.
mysqli_real_connect(): (HY000/2002): Connection refused
I am certain that no configuration files have been changed, it just stopped working, why that might be, and how to prevent it in the future ?
The OS is Ubutnu 18.04.13 (if it matters)

It would appear as if your MySQL daemon is no longer running.
The hints here are that the Laravel app is not able to reach the MySQL server, and that phpMyAdmin is also unable to reach the MySQL server.
You should look in the MySQL error log for hints. You may also find hints in your syslog, depending on how your system is configured. This could give you information about why the service has stopped. You might also find information in the systemd log, which can probably best be viewed with journalctl -u mysql -b.
You could verify that it's actually stopped with systemctl status mysql, even though it's difficult for me to think of a reason why it would be running correctly but not responding to any connection attempts.
Next, you should probably start the service again with sudo systemctl start mysql. If it fails to start, you'll see some information about why not with information about viewing the log file, which you can copy and paste in to your question to help us further with troubleshooting.

Related

MySQL Workbench Failing to Connect to Server (Windows)

There are many errors I have found across the web that deal with MySQL connection errors, but I have found none that address this specific problem that I am having. In short, I have the newest version of the MySQL Server installed (8.0), I have verified it is running in my Services tab, and I can connect to the server via the MySQL client just fine. However, I cannot open a local connection in Workbench.
When I click on the local instance, it hangs until I manually stop it. I then get the aforementioned error
I then went and ran a diagnostic of the server in the MySQL Installer, which reported that everything is working fine (unless I am reading it wrong)
The logs of said diagnostic also report that the server is installed, functional, and running.
I then checked made sure the server was running in Services
After that, I verified that I could connect to the client, and that I could use the database I was working with (info redacted due to it being company property lol)
Additionally, I also made a new connection on Workbench on port 3307 instead of the standard 3306.
When I click on this, I can enter into the connection without getting the "Cannot access a disposed object" error. However, this connection still cannot connect to the server.
I also saw that some people were having success by navigating into C:\Program Files\MySQL\MySQL Server 8.0\bin and running mysqld --install. This appeared to be beneficial, but ended up doing nothing.
Does anyone know how I can fix this without completely uninstalling everything? Everything was working fine yesterday but has suddenly stopped as of this morning.

Unable to connect to localhost:3306 (2003) for MySQL 8.0.21 on Windows

I am using MySQL workbench to connect to my local server. Everything was running fine and suddenly I jumped in a connection refused errors. I tried restarting the server again and again. Clearing temp files and also restarted my machine. I found this post from which I tried a couple of things like net stop and stopping the process from the services list but in the services list it shows as below:
I waited like for 30 mins but still, the service is not stopped.
Also, below is the screenshot for MySQL workbench when I try to start the server:
Is there anything specific which I need to do in order to resolve this error:
So, I resolved my own problem in this way. I referred the documentation for this particular error and for my error which is of 2003 type it said that look for mysqld.exe process in task manager and if you don't find any then start the server. But, in my case I found 2 mysqld.exe processes running. So, I killed those processes and restarted the server. It worked!!
Might help someone someday :)

XAMPP Mysql 2002 error

So I have been trying to get XAMPP up and running for awhile now. I see there is plenty of documentation on this problem but most of them don't seem to be helping my situation so I would really appreciate someones help walking me through this.
Ok when I started apache wouldn't start but when I changed it so that it would be using port 85 that at least started. My next problem has been with MySql. It is currently running on port 3306 (I had something else that was using that port but I deleted it) when I click to start MySql it just says it is attempting to start but doesn't do anything. When I go to phpMyAdmin I get this error message
2002 - No connection could be made because the target machine actively refused it.
The server is not responding (or the local server's socket is not correctly configured).
Are there any procedures I can go though to get this thing up and running?!

ERROR 2013 (HY000): Lost connection to MySQL server at 'reading authorization packet', system error: 0

I am getting the following error
ERROR 2013 (HY000): Lost connection to MySQL server at
'reading authorization packet', system error: 0
when trying to connect to my MySQL server.
What I am doing:
I have Master - Slave replication in MySQL that is working and just added load balance capabilities using F5.
I have configured the F5 according to their site.
But when I am trying to connect to my MySQL server using the IP that the F5 was configured with I get
ERROR 2013 (HY000): Lost connection to MySQL server at
'reading authorization packet', system error: 0
Any ideas?
Update on my progress : ZERO
- i am getting the same error
I get no entries in the /var/log/secure as if somebody would try to authenticate coming form the ip where i had created my load balance server.
No enties in the mysql error log.
The command - returns nothing
mysql> SHOW GLOBAL STATUS LIKE 'Aborted_connections';
Empty set (0.00 sec)
I've already altered my my.cnf file and add the
[mysqld]
skip-name-resolve
Alterd the connect_timeout to 10.
So it seems i get no response for the server i have created on my F5
I finally convinced the F5 admin to pass me the log for the F5 server and i have exctraced all i need form it.
Here is the output :
Jan 28 15:46:39 tmm debug tmm[6459]: Rule /Common/iRule-f5_mysql_proxy <CLIENT_ACCEPTED>: BIG-IP MySQL Proxy -- clientside initial connection
Jan 28 15:46:39 tmm debug tmm[6459]: Rule /Common/iRule-f5_mysql_proxy <CLIENT_ACCEPTED>: BIG-IP MySQL Proxy -- clientside responding with server WELCOME packet
Jan 28 15:46:39 tmm debug tmm[6459]: Rule /Common/iRule-f5_mysql_proxy <CLIENT_DATA>: BIG-IP MySQL Proxy -- clientside authenticated flag not set
Jan 28 15:46:39 tmm err tmm[6459]: Rule /Common/iRule-f5_mysql_proxy <CLIENT_DATA>: BIG-IP MySQL Proxy -- mysql client: attempting to do something before authentication
Jan 28 15:46:39 tmm debug tmm[6459]: Rule /Common/iRule-f5_mysql_proxy <LB_SELECTED>: BIG-IP MySQL Proxy -- serverside selected pool /Common/foss-mysql-slave_pool node SLAVE-IP
Jan 28 15:46:39 tmm debug tmm[6459]: Rule /Common/iRule-f5_mysql_proxy <CLIENT_CLOSED>: BIG-IP MySQL Proxy -- clientside connection closed from MASTER-IP(XXXXXXX)
Jan 28 15:46:39 tmm debug tmm[6459]: Rule /Common/iRule-f5_mysql_proxy <SERVER_CLOSED>: BIG-IP MySQL Proxy -- serverside connection closed from node SLAVE-IP(XXXXXXXX)
I've replaced the ip for security sake !
just as an extra - and i think is here the problem - my mysql version is 5.1.69-log
Thx All
From documentation:
More rarely, it can happen when the client is attempting the initial
connection to the server. In this case, if your connect_timeout value
is set to only a few seconds, you may be able to resolve the problem
by increasing it to ten seconds, perhaps more if you have a very long
distance or slow connection. You can determine whether you are
experiencing this more uncommon cause by using SHOW STATUS LIKE
'aborted_connections'. It will increase by one for each initial
connection attempt that the server aborts. You may see “reading
authorization packet” as part of the error message; if so, that also
suggests that this is the solution that you need.
Try increasing connect_timeout in your my.cnf file
Another style:
MySQL: Lost connection to MySQL server at 'reading initial communication packet'
At some point, it was impossible for remote clients to connect to
the MySQL server.
The client (some application on a Windows platform) gave a vague
description like Connection unexpectedly terminated.
When remotely logging in with the MySQL client the following error
appeared:
ERROR 2013 (HY000): Lost connection to MySQL server at 'reading initial communication packet', system error: 0
On FreeBSD this happens because there was no match found in /etc/hosts.allow. Adding the following line before the line saying ALL:ALL fixes this:
mysqld: ALL: allow
On non-FreeBSD Unix systems, it is worth to check the files /etc/hosts.allow and /etc/hosts.deny. If you are restricting connections, make sure this line is in /etc/hosts.allow:
mysqld: ALL
or check if the host is listed in /etc/hosts.deny.
In Arch Linux, a similar line can be added to /etc/hosts.allow:
mysqld: ALL
This is usually caused by an aborted connect. You can verify this by checking the status:
mysql> SHOW GLOBAL STATUS LIKE 'Aborted_connects';
If this counter keeps increasing as you get the lost connections, that's a sign you're having a problem during connect.
One remedy that seems to work in many cases is to increase the timeout. A suggested value is 10 seconds:
mysql> SET GLOBAL connect_timeout = 10;
Another common cause of connect timeouts is the reverse-DNS lookup that is necessary when authenticating clients. It is recommended to run MySQL with the config variable in my.cnf:
[mysqld]
skip-name-resolve
This means that your GRANT statements need to be based on IP address rather than hostname.
I also found this report from 2012 at the f5.com site (now protected by login, but I got it through Google cache)
It is likely the proxy will not work unless you are running BIG-IP 11.1 and MySQL 5.1, which were the versions I tested against. The MySQL protocol has a habit of changing.
I suggest you contact F5 Support and confirm that you are using a supported combination of versions.
I've struggled a lot with this error. Tried every single answer I found on the internet.
In the end, I've connected my computer to my cell phone's hotspot and everything worked. I turned out that my company's internet was blocking the connection with MySQL.
This is not a complete solution, but maybe someone faces the same problem. It worths to check the connection.
I solved this by stopping mysql several times.
$ mysql.server stop
Shutting down MySQL
.. ERROR! The server quit without updating PID file (/usr/local/var/mysql/xxx.local.pid).
$ mysql.server stop
Shutting down MySQL
.. SUCCESS!
$ mysql.server stop
ERROR! MySQL server PID file could not be found! (note: this is good)
$ mysql.server start
All good from here. I suspect mysql had been started more than once.
My case was that the server didn't accept the connection from this IP. The server is a SQL server from Google Apps Engine, and you have to configure allowed remote hosts that can connect to the server.
Adding the (new) host to the GAE admin page solved the issue.
I have a mac but would assume all linux are the same for this part...
In my case I got this:
2018-12-03 11:13:27 - Start server:
2018-12-03 11:13:27 - Server start done.
2018-12-03 11:13:27 - Checking server status...
2018-12-03 11:13:27 - Trying to connect to MySQL...
2018-12-03 11:13:27 - Lost connection to MySQL server at 'reading authorization packet', system error: 0 (2013)
2018-12-03 11:13:27 - Assuming server is not running
I ran this:
sudo killall mysqld
And then started the mysql again through mysqlworkbench although in your case it might be like this:
mysql.server start
*sidenote: I tried running mysql.server stop and got this Shutting down MySQL
.... SUCCESS! but after running ps aux | grep mysql I saw that it hasn't really shut down...
I use several mysql connections (connecting to different sets of databases) in localhost.
This happened to me after I shut my computer down and mysql was not properly shutdown. After starting my machine I was able to successfully connect to multiple db connections except one (I used this a lot before my machine shutdown).
As per the instructions in this posts I doubled connect_timeout but I was not able to connect to that one database connection.
I restarted my machine and i can successfully connect now. This will help you unblock yourself but it'd be great if it can be fixed without restarting the machine.
Another concern is: connection_timeout seemed to me delay related problem but I was getting the error immediately in localhost when there is no network in the equation.
In my case, it happened when there were a lot of connection to the MySQL server (15,000 connections) and the free memory was about 120M . After I added more memory to the server, the error was gone.
I scratched my head about this error for 3 days. I tried tweaking permissions on the database, new users from different IPs in the Users table, adjusting the bind-address in a bunch of different ways, comparing my my.cnf file to a known working server, firewall changes, upstream firewall changes, hosts.allow/deny...none of them worked.
Then I looked not at mysql/error.log (which came up empty) but my journalctl -xe log and low and behold, it couldn't read my /etc/hosts.allow and my /etc/hosts.deny file.
chmod 644 hosts.allow
chmod 644 hosts.deny.
All better now.
Another possibility can be connection reset from the TCP wrappers (/etc/hosts.deny and /etc/hosts.allow). Just check what is coming in from the telnet to port 3306 - if it is nothing, then there is something is in the middle preventing communication from happening.
I've created my account just to add this bit of information to this old question, because nowhere on the web I found any reference to the cause of my problem which I eventually found.
(Adding it here cause this is the top google result, also when adding PHP as search term)
In PHP 7.4 when you fork a process (I know, who does this??) that has an active MySQL connection, the connection will get messed up and spit out the OP's error.
just reinitialize/recreate the connection in each forked process after the forking, this will fix it.
Hope it this helps anybody.
I got both errors: mostly reading initial communication packet and reading authorization packet one time. It seems random, but sometimes I was able to establish a connection after reboots, but after some time the error creeped back.
Avoiding the 5GHz WiFi in the client seems to have fixed the issue. That's what worked for me (server was always connected to 2.4GHz).
I tried everything from server versions, odbc connector versions, firewall settings, installing some windows update (and then uninstalling them), some of the answers posted here, etc... lost my entire sleep time for today. Super tired day awaits me.
If you get this when using DevDesktop - just restart DevDesktop!

Tomcat7 MySQL Connection Error

I'm facing a perplexing problem. I've completed a jsf web app that utlizes hibernate and infinispan with Tomcat7 and tomcat-jdbc-pool as the connection pool provider.
It is being deployed to a Linode cluster w/ 2 nodes -- one database server and one production server.
I can run the app on my local environment using the exact same copy of Tomcat7 (I literally tarred the tomcat directory and promoted it to the server to debug this error) -- even when connected to the live database instance. Everything runs fine.
When I attempt to run the application from the production server I get a MySQLIO error:
Caused by: java.net.ConnectException:
Connection refused
Looking further up in the logs i see:
The last packet sent successfully to
the server was 1 milliseconds ago. The
driver has not received any packets
from the server.
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException:
Communications link failure
I can connect from the command line on the prodapp server just fine -- even using tcp:
mysql -h db01 -u user -p --protocol=tcp
But it just won't work running inside the Tomcat container. I've tried all kinds of things but I'm really stumped. It just seems strange that I can connect to the database server using the same copy of Tomcat7 locally but when deployed to production the same copy of tomcat7 can't connect -- even though I can connect from the command line on that production server ... I'm stumped.
Any help is greatly appreciated.
EDIT: Solved my problem after wasting too much good life on it. The answer was I'm stupid. Thanks to everyone who tried to help. I have the app moded w/ a dev and live mode and the connection pool was reading the dev mode this whole time. What really made it confusing is that the sessionfactory was moded to live so it would actually reach the live database and initialize a connection when it started up so i could see it connecting (and running meta data queries in the mysql log), but when it actually went to grab a connection from infinispan it blew up. Oh well -- at least it's working now. Thanks again.
If you're connecting to your MySQL database server from a different box, then you need to explicitly grant permission for that user account to connect from that IP.
You can do this whilst in the command line:
GRANT ALL PRIVILEGES ON *.* TO 'username'#'ip_address'
EDIT: Granting all permissions on all tables generally isn't required, be specific about what permissions you want to grant (http://dev.mysql.com/doc/refman/5.1/en/grant.html)
To see what permissions you currently have:
USE mysql;
SELECT * FROM users;
My apologies if I'm patronising you, just that this is the most common problem that I come across.