My hosting provider is giving me a host for my database.
But I can't access this host from my symfony project:
An exception occurred in driver: SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: nodename nor servname provided, or not known
here is my .env:
DATABASE_URL=mysql://esoh_metask:mypassword#esoh.myd.infomaniak.com:3306/esoh_task_db
When i ping my host, i get an error saying that is it not known.
The hostname esoh.myd.infomaniak.com resolves to the IP address 10.4.27.10.
10.*.*.* addresses are all for private use within data centers. So, if you're trying to run your symfony program on your own machine (office or home) you won't be able to reach that MySQL server -- it's behind a firewall at your vendor.
Ask your vendor for help.
Related
I'm having an issue with my Plesk installation. When I attempt to manage my database it says "The server is unavailable". When I try to create a new database it gives the following error:
ERROR: SQLSTATE[HY000] [2002] No connection could be made because the
target machine actively refused it
I've already tried restarting the Plesk SQL service. I've also tried repairing Plesk via the command line tool but it gives the same error.
Does anyone know what could be the problem? Or where I can find more logs to get a more specific error?
I aam trying to create a new doctrine database using Symfony 5.
Recently Symfony changed using mysql by default to using pstgreSQL.
As I want to use mysql I changed the comment in .env from :
# DATABASE_URL="mysql://db_user:db_password#127.0.0.1:3306/db_name?serverVersion=5.7"
DATABASE_URL="postgresql://db_user:db_password#127.0.0.1:5432/db_name?serverVersion=13&charset=utf8"
to
# DATABASE_URL="mysql://root:#127.0.0.1:3306/mywebsite?serverVersion=5.7"
DATABASE_URL="mysql://root:d#127.0.0.1:5432/mywebsite?serverVersion=13&charset=utf8"
in other words I just changed postgresql to mysql and commented what needs to be commented.
However when I run
php bin/console doctrine:database:create
I get the following error :
In AbstractMySQLDriver.php line 112:
An exception occurred in driver: SQLSTATE[HY000] [2002] No connection
has been established as the target computer rejected it (translated
from french)
I found the following posts :
An exception occurred in driver: SQLSTATE[HY000] [2002] Connection refused
and
In AbstractMySQLDriver.php line 112:
An exception occurred in driver: SQLSTATE[HY000] [2002] php_network_getaddr
esses: getaddrinfo failed: Hte inconnu.
in short both tells me to change "127.0.0.1" by "mysql"
but when running as such I get this error
In AbstractMySQLDriver.php line 112:
An exception occurred in driver: SQLSTATE[HY000] [2002]
php_network_getaddr esses: getaddrinfo failed: Hte inconnu.
What mistake did I do or what did I miss?
Thank you
I found a very simple solutionthat will seems obvious for experienced dev but not for beginners that is never talked about.
just change the # at the beginning of the first line
# DATABASE_URL="mysql://root:#127.0.0.1:3306/mywebsite?serverVersion=5.7"
DATABASE_URL="mysql://root:d#127.0.0.1:5432/mywebsite?serverVersion=13&charset=utf8"
to the second line
DATABASE_URL="mysql://root:#127.0.0.1:3306/mywebsite?serverVersion=5.7"
# DATABASE_URL="mysql://root:d#127.0.0.1:5432/mywebsite?serverVersion=13&charset=utf8"
You can found documentation here https://www.doctrine-project.org/projects/doctrine1/en/latest/manual/introduction-to-connections.html
In your config the port 5432 is not default port of Mysql
Try
DATABASE_URL="mysql://root:d#127.0.0.1:3306/mywebsite?serverVersion=13&charset=utf8"
Hi i installed Shopware developer project like here and it works fine but i can't login into database. I am getting error if i tried ./psh.phar administration:watch or ./psh.phar administration:build ->
In AbstractMySQLDriver.php line 93:
An exception occurred in driver: SQLSTATE[HY000] [2002] php_network_getaddr
esses: getaddrinfo failed: nodename nor servname provided, or not known
In PDOConnection.php line 31:
SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: nodena
me nor servname provided, or not known
In PDOConnection.php line 27:
SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: nodena
me nor servname provided, or not known
In PDOConnection.php line 27:
PDO::__construct(): php_network_getaddresses: getaddrinfo failed: nodename
nor servname provided, or not known
Execution aborted, a subcommand failed!
I tried also login in adminer with credentials what are in docker-compose.yml and i am getting same error. Do you have any ideas? 😇
UPDATE
I had to first time start ./psh.phar docker:ssh and then follow commannd ./psh.phar administration:build. Now everythink working fine :)
The Docker Hub page for MySQL has many useful information on how to use MySQL with Docker.
In your docker-compose/Dockerfile filess make sure to provide the environment-variables required by MySQL, e.g.: MYSQL_ROOT_PASSWORD.
Also, make sure to read Shopware documentation to make sure you are providing all the required values in your docker-compose/Dockerfile files.
In my docker-compose.yml i have this enviroment configuration
MYSQL_ROOT_PASSWORD: root
MYSQL_USER: app
MYSQL_PASSWORD: app
If i launch my app on localhost:8000 evereythink working so it's mein that app can log into database but from console or adminer i can't. :-/
Please take a look weather the mysql container started. You can use docker ps -a for it.
If not, use docker logs ${containerId} for showing information why it not started.
Also post a ./psh.phar docker:start here.
I have a docker-compose.yml and a Dockerfile that create containers for an app in Symfony 2.8.
The containers are called: webserver (Nginx), app (Symfony) and db (MySql).
When I create the containers, I can easily access the bash of the app and run php app/console doctrine:migrations:migrate. Everything works fine.
I would like to insert the command in the Dockerfile, like this:
RUN cd /var/www && php app/console doctrine:migrations:migrate
but, when it arrives at that point, it just returns:
[Doctrine\DBAL\Exception\ConnectionException]
An exception occured in driver: SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known
[Doctrine\DBAL\Driver\PDOException]
SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known
[PDOException]
SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known
[PDOException]
PDO::__construct(): php_network_getaddresses: getaddrinfo failed: Name or service not known
doctrine:migrations:migrate [--write-sql] [--dry-run] [--query-time] [--allow-no-migration] [--configuration [CONFIGURATION]] [--db-configuration [DB-CONFIGURATION]] [--db DB] [--em EM] [--shard SHARD] [--] [<version>]
ERROR: Service 'app' failed to build: The command '/bin/sh -c cd /var/www && php app/console doctrine:migrations:migrate' returned a non-zero code: 1
What could the problem be? It works after I access the bash in the container, but not automatically from the script.
While the image is being built, it's not yet running on a container and attached to the network to be able to see the other containers defined in our docker-compose.yml file.
Not only doing DB migration during the image build is a bad idea: it's not possible if the DB it depends on it is running on a different container and trying to reach it through its internal network name.
If the DB server is connected, which was already running and had a publicly reachable hostname, and the project was configured to use that server instead of one running in another container, it would work. But it would still be a bad idea.
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