PDOException Occurs in doctorline:generate:entity

Asked 1 years ago, Updated 1 years ago, 97 views

PDOException occurs when I try to create a model with symfony2

The Entity shortcut name:QuartetBlogBundle:Post

→ Enter results in the following error

 [Doctorline\DBAL\Exception\ConnectionException] 
An exception occurred driver: SQLSTATE [HY000] [2002] Connection refused 

Doctrine\DBAL\Driver\PDOException 
SQLSTATE [HY000] [2002] Connection refused

The unix_socket in config.yml looks like this

doctrine:
dbal:
    driver —pdo_mysql
    host: "%database_host%"
    port: "%database_port%"
    dbname: "%database_name%"
    user: "%database_user%"
    password: "%database_password%"
    charset —UTF8
    unix_socket: same as /Applications/MAMP/tmp/mysql/mysql.sock/php.ini

Is there any misconfiguration here?
Or, if you can do doctorline:generate:entity other than the above, please let me know how to do it.

php mysql symfony2

2022-09-30 21:11

1 Answers

An exception occurred driver: SQLSTATE [HY000] [2002] Connection refused

I think it's because I can't connect to MySQL.

Does %database_host% have a value of 127.0.0.1?
If skip-networking is configured on the MySQL side, 127.0.0.1 cannot connect.(because they are rejecting the TCP connection.)
In that case, localhost should be used to connect to (because it will be connected via Unix domain socket).

It's not a Symfony problem, it's a MySQL configuration problem, so you should reconsider the configuration.

Reference: http://qiita.com/mpyw/items/b00b72c5c95aac573b71#comment-e9db50fff9bffa1dd6f8


2022-09-30 21:11

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.