connecting to database fails with laravel mysql - mysql

my project is hosted in forge (digital ocean) laravel 5.1
I can connect (ssh) normally with putty using ssh file key by taping only the username but I fail when I try to connect to database with heidisql with the same ssh key file , I used to connect normally but the last month after a payment problem i always fail and i Get
Lost connection to MySQL server at 'reading initial communication packet', system error: 0
and in the webpage I get
[PDOException] SQLSTATE[HY000] [2002] Connection refused
any solution please

solved by sudo service mysql restart

Related

Problems connecting Laravel to a remote MySQL database: "Lost connection to MySQL server at handshake" and "MySQL server has gone away"

I got this problem where I have developed a Laravel application which uses or connects to a external database.
I have copied all Laravel files in a CentOS server that needs to connect to a MySQL database that is located in another (Ubuntu) server.
Locally, I didn't have any trouble with Laravel Homestead.
But now the Laravel app throws the following error:
SQLSTATE[HY000] [2006] MySQL server has gone away
And if I try to connect to the external database from the CentOS terminal,
$ mysql -h xxx.xxx.xxx.xxx -P 3306 -u user4laravel -p
I get this other error:
ERROR 2013 (HY000): Lost connection to MySQL server at 'handshake:
reading inital communication packet', system error: 11
Notes: I connect to that server via SSH Tunnel with SSH-KEY and passphrase. Do I have to create a tunnel connection?
How do I make it persistent? Is this practical? Or ...
Does anybody know how to solve this or a workaround?

Can't connect to remote MySQL server Error 2003 (HY000)

Sorry but I started this thread because I couldn't found a solution.
I'm using MySQL Router and InnoDB Cluster to deploy a sandbox cluster. I've followed the documentation see here and here , but when I try to connect by mysqlsh --uri root#localhost:6446, it outputs this following error:
MySQL Error 2003 (HY000): Can't connect to remote MySQL server for client connected to '127.0.0.1:6446'
What am I missing?
Maybe you can check the myrouter log?
In my log it shows the following:
Failed connecting with Metadata Server mysql-db1.mjdh.local:3308: Unknown MySQL server host 'mysql-db1.mjdh.local' (110) (2005)
So I write it in hosts and the problem missed.

laravel mysql timeout when connecting to remote digital ocean database server on local network

My laravel installation is having some issues connecting to the MySQL database. I am also using laravel doctrine.
The mysql server is on a separate digital ocean droplet.
Mysql server listens on a non standard port, is bound only to the local network interface (eg 10.131.xx.xx)
The mysql database has a non root user which has host access configured
The mysql server has iptables configured to only allow the webserver ip to connect to the non standard port on bound ip
my .env file is configured as so
DB_CONNECTION=mysql
DB_DATABASE=$CORRECT_USER
DB_HOST=$CORRECT_TARGET_LOCAL_IP
DB_USERNAME=$CORRECT_DB_USR
DB_PASSWORD=$CORRECT_PASS
DB_PORT=$CORRECT_PORT
to sanity check my env
i have tried connecting directly to mysql as followed
$ mysql -u$CORRECT_DB_USR -p$CORRECT_PASS -h$CORRECT_TARGET_LOCAL_IP
--port=$CORRECT_PORT $CORRECT_USER
which connects correctly
as well as telnetting the target as followed
$ telnet $CORRECT_TARGET_LOCAL_IP $CORRECT_PORT
which prints
Escape character is '^]'. [
my-os-and-version1"||xgpK(iqJmysql_native_password
but when i run the command php artisan doctrine:schema:create
the following errors are shown
[Doctrine\DBAL\Exception\ConnectionException] An
exception occured in driver: SQLSTATE[HY000] [2002] Connect ion
timed out
[Doctrine\DBAL\Driver\PDOException] SQLSTATE[HY000] [2002]
Connection timed out
[PDOException] SQLSTATE[HY000] [2002] Connection timed
out
I have tailed the ufw.log and the mysql error log, on the mysql server no packets are dropped by the firewall and no incorrect credential errors are thrown from the mysql log
does any one have any idea what this might be

Openshift mysql connection error channel timeout

I have an Tomcat 7 application on openshift and I have added a MySQL cartridge. I have a problem connecting to that database using MySQL workbench.
I have added all the necessary parameters like hostname, username, password and SSH key, I have tested the connection and I get no errors. But when I try to connect to the db I get the following error:
Your connection attempt failed for user 'adminxxxx' from your host to server xx.xxx.xxx.xxx:3306:
Tunnel error: Remote connection to xx.xxx.xxx.xxx:3306 failed: IOError('open SSH tunnel timeout',)
What can I do to fix this? Connecting to the db is a big part of the application.

Failed connection to amazon RDS

I can connect to my Amazon RDS MYSQL instance from the following
EC2 instance in both command line and usin mysql workbench
From an Excel Worksheet using the mysql driver and an odbc, on my laptop.
However from my laptop I can not connect to the instance from
Command Line
Mysql Workbench
TELNET TEST
N
5.5.40-log</UA"%2kF☻└§\ypC#Td}fhWYmysql_native_password
connection to host lost.
MYSQL CMD LINE ERROR
Warning: Using a password on the command line interface can be insecure. ERROR 2013 (HY000): Lost connection to MySQL server at 'reading authorization packet', system error: 2
CURRENT SITUATION
I am running windows.
I have checked the amazon service is healthy
I have checked another internet connection.
I have had this error before but it just sorted itself out.
I have not been able to access MYSQL for over 24hours from cmd or
workbench or telnet but I can from EC2 and Excel.
Security group settings are open to anyone. Has been like that for 1 year
The log shows some IP failed attempts from unkown IPs, one was in China, I am in the UK.
Secure groups have been added to the instance.
UPDATE
It appears that I can access the RDS MYSQL server from Starbucks. This issue must relate to my internet provider at home. What could I ask the internet provider to check?