I'm a fresh junior php developer and I'm building my first Symfony project.
When I used the command : php bin/console doctrine:database:create
I get these errors :
In AbstractMySQLDriver.php line 93:
An exception occurred in driver: SQLSTATE[HY000] [2002] No such file or directory
In PDOConnection.php line 31:
SQLSTATE[HY000] [2002] No such file or directory
In PDOConnection.php line 27:
SQLSTATE[HY000] [2002] No such file or directory*
I'm actually using MAMP with default config "db_user" and "db_password"
so I edited the .env file with this following code :
DATABASE_URL=mysql://root:root#localhost:8889/mydbname
I know there is something wrong with my host or port, I saw on other topics that some users using MAMP keep Symfony default values for host and port : DATABASE_URL=mysql://root:root#127.0.0.1:3306/mydbname
Thanks for reading me and trying to help me.
I did more searches and some people are saying that localhost syntax is depreciated and prefer using : 127.0.0.1 instead of localhost.
In my case I checked and used Mamp config 'Connect using an UNIX socket'
So it's now working with :
DATABASE_URL=mysql://root:root#127.0.0.1:8889/mydbname
Related
Using Laravel 8
Ubuntu 20.04 with Docker
Connect to Database over clients worked perfect. Docker-Container worked.
If I dont start it with php artisan serve it refused the connection to mysql.
With php artisan serve it connects to mysql-docker-container.
I want deploy it. But if I make it like this doc: https://laravel.com/docs/8.x/deployment
it worked fine, but only DB-connection crashes.
I tried: SQLSTATE[HY000] [2002] Connection refused within Laravel homestead
But if I change the Host it answer with this mistake: PDOException: SQLSTATE[HY000] [2002] No such file or directory
need help.
dont forget... WSL :)
use mysql not localhost.
I have the default config in my symfonu project I have this line at .env file
DATABASE_URL="postgresql://db_user:db_password#127.0.0.1:5432/db_name?serverVersion=13&charset=utf8"
and I get this error
An exception occurred in driver: SQLSTATE[08006] [7] could not connect to server: Connection refused
Is the server running on host "127.0.0.1" and accepting
TCP/IP connections on port 5432?
Of course I dont have not isntalled postgres, and I dont need a database for this project, How I cant fix this error I tried to comment the .env file line but I get another error
Commenting the line as L3xpert answer suggests doesn't seem to do the job.
It will throw the error :
Environment variable not found: "DATABASE_URL".
If you don't need Doctrine but you have Website-Skeleton installed, you can remove Doctrine by running this command :
composer remove doctrine/doctrine-bundle doctrine/doctrine-migrations-bundle
I've installed eZ Platform on my Mac using the eZ Launchpad docs: https://ezsystems.github.io/launchpad/.
After the installation, I'm able to successfully access the platform and start creating the Content Model.
I would also like to use GraphQL, so I followed the instructions: https://doc.ezplatform.com/en/latest/api/graphql/.
Unfortunately I get an error when I try to generate the schema using the commands:
php bin/console ezplatform:graphql:generate-schema
php bin/console cache:clear
This is the error I get:
In ExceptionConversion.php line 169:
Database error
In AbstractMySQLDriver.php line 93:
An exception occurred in driver: SQLSTATE[HY000] [2002] No such file or directory
In PDOConnection.php line 31:
SQLSTATE[HY000] [2002] No such file or directory
In PDOConnection.php line 27:
SQLSTATE[HY000] [2002] No such file or directory
Here's the app/config/parameters.yml:
# This file is auto-generated during the composer install parameters:
env(SYMFONY_SECRET): ThisEzPlatformTokenIsNotSoSecret_PleaseChangeIt
env(DATABASE_DRIVER): pdo_mysql
env(DATABASE_HOST): localhost
env(DATABASE_PORT): null
env(DATABASE_NAME): ezplatform
env(DATABASE_USER): root
env(DATABASE_PASSWORD): null
env(DATABASE_CHARSET): utf8mb4
env(DATABASE_COLLATION): utf8mb4_unicode_520_ci
env(DATABASE_VERSION): mariadb-10.2.26
Looks like you have executed the composer and symfony commands directly from your host and you have setup the project using launchpad.
Try this instead:
~/ez sfrun ezplatform:graphql:generate-schema
~/ez sfrun cache:clear
With ezlaunchpad your app is running in the docker container so you have to execute all common symfony/ez commands through the ~/ez shell. Executing commands from host can lead to file permission issues as well.
Symfony4
PHP 7.2.19
Ubuntu Linux 18.04.2 ( Up to date)
MySQL 5.7.27
Its seems like I cannot get access to my database.
I do have access to phpMyAdmin with the same user & password.
I downloaded a D8 to test if it is working with this installation:
Surprisingly it works, with the same user I can set up a D8 installation.
If I download a fresh Symfony4 project the issue persists.
Its the first time I got this issue,
.env
DATABASE_URL=mysql://user:userPW#localhost:3306/db
This is my CLI output:
In AbstractMySQLDriver.php line 93:
An exception occurred in driver: SQLSTATE[HY000] [1045] Access denied for user ..
We have a working app that successfully returns a token from /auth/user-token using Symfony 4 and Lexik JWT Authentication Bundle. After I install JWTRefreshTokenBundle, (completing the installation up through step 3), however, I get this error when visiting that existing endpoint:
An exception occurred in driver: SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known
Reverting my files to a pre-installation state allows the app to work again.
Does anyone have any ideas about what might be going on here?
===
Update: Attempting to run the installation through step 5 (schema update) results in this error:
In AbstractMySQLDriver.php line 113:
An exception occurred in driver: SQLSTATE[HY000] [2002] Connection refused
In PDOConnection.php line 50:
SQLSTATE[HY000] [2002] Connection refused
In PDOConnection.php line 46:
SQLSTATE[HY000] [2002] Connection refused
You have to install mysql and then add the following line to your .env file at symfony root:
DATABASE_URL="mysql://db_user:db_password#127.0.0.1:3306/db_name"
Then replace the following values with desired values:
db_user your database user
db_password your database password
db_name your database name
Then do the following changes in config/packages/doctrine.yaml:
doctrine:
dbal:
url: '%env(DATABASE_URL)%'