I have a service deployed in mesos, which queries a remote database server. I used github.com/go-sql-driver/mysql to query the database from my Go code. It was working fine for about a week. But today I got this error: driver: bad connection
So I entered the docker container where my service runs and type in command line:
mysql -uxxx -hx.x.x.x -Pxxx -Dxxx -pxxx
Here's the response:
ERROR 2013 (HY000): Lost connection to MySQL server at 'reading initial communication packet', system error: 0
This is the content of /etc/mysql/my.cnf file:
[mysql]
no-auto-rehash # Faster start of mysql but no tab completition
What can be the error here? And how can I solve this?
Edit: When I run the same command from my local machine it works fine. I can query the database from the command line of my pc.
Related
After installing Mariadb on Debian 9, I am trying to run /usr/bin/mysql_secure_installation. The script starts okay, but after I press 'enter' for no root password, I get the following error:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2 "No such file or directory")
I have to ctl-c to get out of the script.
The socket is set in /etc/mysql/debian.cnf to /var/run/mysqld/mysqld.sock
It is also set in /etc/mysql/mariadb.conf.d/50-server.cnf to /var/run/mysqld/mysqld.sock
The server is not running.
After digging around many, many places, the answer was right under my nose on the Troubleshooting Connection Issues page at the MariaDB website 1
The error means that the server is either not running or running on a different port, socket or pipe. Since I knew the server was not running, I started it with
/etc/init.d/mysql start
before running the script and no more problems with the error or the script.
I know this is a common issue. But I shut the DB server down with the Unix "service mysqld stop" command then restarted the server soon after with the "service mysqld start" command. I did it to flush out a couple of "killed" MySQL processes.
Checking, I get the
service mysqld status
mysqld (pid 19354) is running...
But on my webpages that access the DB I get the error "The Database Connection Is Down: Lost connection to MySQL server at 'reading initial communication packet', system error: 111"
So all I did was shut the DB server down and started it up again a minute later. How long will the problem persist, or is there more I should do?
Your host is wrong, your port is wrong, a firewall blocked the connection, or the SQL server is not running. 111 is "connection refused". You can troubleshoot by trying to telnet to the SQL server's host and port. If that works, your code gets the host or port wrong.
If that doesn't work, check on the SQL server itself. If it works there, the problem is the network. If it doesn't work there, the SQL server is not running.
Be sure the mysql is running: service mysqld status or try with PHPmyadmin
I'm running a simple query on the MySQL server (5.7.20) inside Docker container.
Query is run from a BASH script inside the same container. Variables are exported and defined. Credentials are checked and valid.
mysql --user="root" --password="${MYSQL_ROOT_PASSWORD}" --show-warnings --verbose -e "DROP DATABASE IF EXISTS ${MYSQL_TEST_DB};"
There is no firewall problem since the MySQL server is binned to 127.0.0.1. Running and connecting also from localhost.
/etc/hosts does have a 127.0.0.1 localhost defined.
Service is running and I'm able to login to MySQL over CLI with the same credentials.
tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN
Full error message shows
ERROR 2013 (HY000): Lost connection to MySQL server at 'reading
initial communication packet', system error: 104
Not finding anything useful on Google or SO and running out of ideas.
Most of the answers are connected to firewall or timeout answers.
I am trying to setup mysql on ubuntu server 17.04 so i can access it remotely.
Currently it is up and running, i can access it locally or if i SSH in first, but when i try to connect using mysql -h <ip> -u <admin> -p on my linux mint machine.
It gives me ERROR 2013 (HY000): Lost connection to MySQL server at 'reading initial communication packet', system error: 104
Here is my /etc/mysql/my.cnf
[mysqld]
bind-address = 0.0.0.0
skip-name-resolve
I currently have my firewall off on both machines
my user is CREATE USER '<username>'#'%' AS IDENTIFIED BY '<Password>'
I have rebooted the server multiple times, restarted the service, havent gotten it to work yet.
I have also tried to connect using HeidiSQL on my windows machine, i get the same error.
Not sure what else to try
It was an issue with internal port blockage
I use Ubuntu 12.04 x64, currently with Mysql 5.5.28 (plus Galera, but I don't think it's related).
I made some changes in my.cnf, but changes was related to InnoDB settings (a lot more memory for the buffer pool, flush, thread concurrency settings etc.).
After that when I hit service mysql restart I cannot enter mysql console - I get following error message:
Lost connection to MySQL server at 'reading initial communication packet',
system error: 104
Sometimes next try results in entering console, sometimes not and I have to restart my SSH connection. What could be the problem and how to fix it?
EDIT:
I noticed that most of the time after the system error: 104 following error occurs:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket
'/var/run/mysqld/mysqld.sock' (111)
After few times it usually starts. Unfortunately now it didn't and in syslog there is:
Error in my_thread_global_end(): 2 threads didn't exit
Restarting SSH connection / MySQL server is not working. I can try reboot server but I'd try to resolve this without that step. Its testing environment so I want to find better solution than restart whole server ;)
Please try the answers in this page:- Lost connection to MySQL server at 'reading initial communication packet', system error: 0
Also try this.