MYSQL error SQLSTATE [HY000] [2003] when connecting to a remote database

0

I would like for you to please help me with this problem. I have two virtual machines in virtualbox the first on the web server (192.168.0.20 centos 6.8) and the second is the database server (192.168.0.50 centos 7)

I have created a laravel application and I am receiving this error in the log

local.ERROR: PDOException: SQLSTATE[HY000] [2003] Can't connect to MySQL server on '192.168.0.50' (13) in /var/www/html/laravel/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:119

this is my my.cnf file

[mysqld]
port = 3337
#bind-address = 127.0.0.1
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd

[mysqld_safe]
log-error=/var/log/mariadb/mariadb.log
pid-file=/var/run/mariadb/mariadb.pid

#
# include all files from the config directory
#
!includedir /etc/my.cnf.d

and this is my .env file from laravel

B_CONNECTION=mysql
DB_HOST=192.168.0.50
DB_PORT=3337
DB_DATABASE=darwindeveloper
DB_USERNAME=admindb
DB_PASSWORD=admindb

on my database server I execute the following command

mysql -u admindb -h 192.168.0.20 -P 3337 -p
Enter password:
ERROR 2003 (HY000): Can't connect to MySQL server on '192.168.0.20' (111)

Any idea how to solve it?

Thank you for your attention

    
asked by Darwin Morocho 11.02.2017 в 19:36
source

1 answer

0

Your database server is at 192.168.0.50 and you are trying to connect to 192.168.0.20 ???

mysql -u admindb -h 192.168.0.20 -P 3337 -p

Since you have a virtualbox, I recommend using Vagrant and Homestead .

    
answered by 14.02.2017 в 10:19