This question already has answers here:
PDO: Could not find driver php/mysql
(2 answers)
Closed 7 years ago.
Please help me I am doing Symblog tutorial that is unfortunately filled with mistakes so I need to seek your wisdom. I am in the part of the tutorial where I need to use 2 commands
$ php app/console doctrine:database:create
$ php app/console doctrine:schema:create
but after I use first one I get red error in cli:
Could not create database `symblog_db` for connection named default
could not find driver
I checked another topics and they say I have to ensure that my apache and cli uses the same php.ini file. I checked it - they don't, so what now? Copy php.ini from cli and overwrite apache one or other way around?
I use XAMPP on Ubuntu
Here is extension part of /opt/lampp/etc/php.ini
;extension=php_bz2.dll
;extension=php_curl.dll
;extension=php_dba.dll
;extension=php_exif.dll
;extension=php_fileinfo.dll
;extension=php_gd2.dll
;extension=php_gettext.dll
;extension=php_gmp.dll
;extension=php_intl.dll
;extension=php_imap.dll
;extension=php_interbase.dll
;extension=php_ldap.dll
;extension=php_mbstring.dll
;extension=php_ming.dll
;extension=php_mssql.dll
extension=php_mysql.dll
;extension=php_mysqli.dll
;extension=php_oci8.dll ; Use with Oracle 10gR2 Instant Client
;extension=php_oci8_11g.dll ; Use with Oracle 11g Instant Client
;extension=php_openssl.dll
;extension=php_pdo_firebird.dll
;extension=php_pdo_mssql.dll
;extension=php_pdo_mysql.dll
;extension=php_pdo_oci.dll
;extension=php_pdo_odbc.dll
extension=php_pdo_pgsql.dll
;extension=php_pdo_sqlite.dll
extension=php_pgsql.dll
;extension=php_phar.dll
;extension=php_pspell.dll
;extension=php_shmop.dll
;extension=php_snmp.dll
;extension=php_soap.dll
;extension=php_sockets.dll
;extension=php_sqlite.dll
;extension=php_sqlite3.dll
;extension=php_sybase_ct.dll
;extension=php_tidy.dll
;extension=php_xmlrpc.dll
;extension=php_xsl.dll
;extension=php_zip.dll
;extension="zip.so"
;extension="sqlite.so"
;extension="radius.so"
;extension="pgsql.so"
; disabled in XAMPP 1.7.2 because incompatible with PHP 5.3.0
;extension="dbx.so"
;extension="ming.so"
;extension="ncurses.so"
;extension="dio.so"
;extension="interbase.so"
; disabled in XAMPP 1.7.2 because incompatible with PHP 5.3.0
;extension="eaccelerator.so"
;eaccelerator.shm_size="16"
;eaccelerator.cache_dir="/opt/lampp/temp/eaccelerator"
;eaccelerator.enable="1"
;eaccelerator.optimizer="1"
;eaccelerator.check_mtime="1"
;eaccelerator.debug="0"
;eaccelerator.filter=""
;eaccelerator.shm_max="0"
;eaccelerator.shm_ttl="0"
;eaccelerator.shm_prune_period="0"
;eaccelerator.shm_only="0"
;eaccelerator.compress="1"
;eaccelerator.compress_level="9"
/etc/php5/cli/php.ini does not appear to have any extensions.
Here is my app/config/parameters.yml (obviously i put real password in my file)
database_driver: pdo_mysql
database_host: 127.0.0.1
database_port: null
database_name: symblog_db
database_user: root
database_password: null
mailer_transport: "gmail"
mailer_encryption: "ssl"
mailer_auth_mode: "login"
mailer_host: "smtp.gmail.com"
mailer_user: "mactestsymblog#gmail.com"
mailer_password: "xxxxxxxxx"
secret: JaTylkoTrenuje
and app/config/config.yml
imports:
- { resource: parameters.yml }
- { resource: security.yml }
- { resource: services.yml }
- { resource: #BloggerBlogBundle/Resources/config/config.yml }
# Put parameters here that don't need to change on each machine where the app is deployed
# http://symfony.com/doc/current/best_practices/configuration.html#application-related-configuration
parameters:
locale: en
framework:
#esi: ~
#translator: { fallbacks: ["%locale%"] }
secret: "%secret%"
router:
resource: "%kernel.root_dir%/config/routing.yml"
strict_requirements: ~
form: ~
csrf_protection: ~
validation: { enable_annotations: true }
#serializer: { enable_annotations: true }
templating:
engines: ['twig']
#assets_version: SomeVersionScheme
default_locale: "%locale%"
trusted_hosts: ~
trusted_proxies: ~
session:
# handler_id set to null will use default session handler from php.ini
handler_id: ~
fragments: ~
http_method_override: true
# Twig Configuration
twig:
debug: "%kernel.debug%"
strict_variables: "%kernel.debug%"
# Assetic Configuration
assetic:
debug: "%kernel.debug%"
use_controller: false
bundles: [ ]
#java: /usr/bin/java
filters:
cssrewrite: ~
#closure:
# jar: "%kernel.root_dir%/Resources/java/compiler.jar"
#yui_css:
# jar: "%kernel.root_dir%/Resources/java/yuicompressor-2.4.7.jar"
# Doctrine Configuration
doctrine:
dbal:
driver: pdo_mysql
host: "%database_host%"
port: "%database_port%"
dbname: "%database_name%"
user: "%database_user%"
password: "%database_password%"
charset: UTF8
# if using pdo_sqlite as your database driver:
# 1. add the path in parameters.yml
# e.g. database_path: "%kernel.root_dir%/data/data.db3"
# 2. Uncomment database_path in parameters.yml.dist
# 3. Uncomment next line:
# path: "%database_path%"
orm:
auto_generate_proxy_classes: "%kernel.debug%"
naming_strategy: doctrine.orm.naming_strategy.underscore
auto_mapping: true
# Swiftmailer Configuration
swiftmailer:
transport: "%mailer_transport%"
host: "%mailer_host%"
username: "%mailer_user%"
password: "%mailer_password%"
spool: { type: memory }
I could add phpinfo but It will exceed the question allowed length. Please help me.
It's look like you should uncoment string "extension=php_pdo_mysql.dll".
When cli and http uses different .ini files - it's not a problem, it's a different environments with different preferences.
But I din't understand, why extensions has .dll extension if you use Ubuntu.
I uncommented this line extension=php_pdo_mysql.dll and it works for me..
Related
My SF3 application is working just fine in dev built-in PHP server. However some assets give me an error when getting to a production Apache server : the images are showing a 404 error, and a Bundle triggers a 505 code. Here's 2 screens of the Chrome console where you can see the errors :
Dev:
Prod:
I've been trying many things (checking the Apache conf files, emptying the cache, the install:assets command even thoug I'm just using the classic Twig syntax and no Assetic, etc) and browsed tons of topics over the internet in vain.
Here's my config.yml file just in case :
imports:
- { resource: parameters.yml }
- { resource: security.yml }
- { resource: services.yml }
- { resource: "#ABundle/Resources/config/services.yml" }
- { resource: "#AnotherBundle/Resources/config/services.yml" }
# Put parameters here that don't need to change on each machine where the app is deployed
# http://symfony.com/doc/current/best_practices/configuration.html#application-related-configuration
parameters:
locale: en
framework:
#esi: ~
#translator: { fallbacks: ["%locale%"] }
secret: "%secret%"
router:
resource: "%kernel.root_dir%/config/routing.yml"
strict_requirements: ~
form: ~
csrf_protection: ~
validation: { enable_annotations: true }
#serializer: { enable_annotations: true }
templating:
engines: ['twig']
default_locale: "%locale%"
trusted_hosts: ~
trusted_proxies: ~
session:
# http://symfony.com/doc/current/reference/configuration/framework.html#handler-id
handler_id: session.handler.native_file
save_path: "%kernel.root_dir%/../var/sessions/%kernel.environment%"
# save_path: /var/lib/php/sessions
fragments: ~
http_method_override: true
assets: ~
php_errors:
log: true
# Twig Configuration
twig:
debug: "%kernel.debug%"
strict_variables: "%kernel.debug%"
paths:
"%kernel.root_dir%/../app/Resources/views/modules": modules
# Doctrine Configuration
doctrine:
dbal:
driver: pdo_mysql
host: "%database_host%"
port: "%database_port%"
dbname: "%database_name%"
user: "%database_user%"
password: "%database_password%"
charset: UTF8
# if using pdo_sqlite as your database driver:
# 1. add the path in parameters.yml
# e.g. database_path: "%kernel.root_dir%/../var/data/data.sqlite"
# 2. Uncomment database_path in parameters.yml.dist
# 3. Uncomment next line:
#path: "%database_path%"
orm:
auto_generate_proxy_classes: "%kernel.debug%"
naming_strategy: doctrine.orm.naming_strategy.underscore
auto_mapping: true
# Swiftmailer Configuration
swiftmailer:
transport: "%mailer_transport%"
host: "%mailer_host%"
username: "%mailer_user%"
password: "%mailer_password%"
spool: { type: memory }
I'm really stuck on this one, so thank you in advance guys.
have you tried: php bin/console assetic:dump --env=prod --no-debug ?
also, your assets should be in src/YourBundle/Resources/public directory. Then when you install them with php bin/console assets:install --symlink they should be copied or symlinked to web/bundles/your directory
So the problem was that my assets were in the web folder instead of the Resources. Then the assetic:dump command worked perfectly.
Thanks a lot
EDIT2: APC is installed and enabled. what would be the solution?
I'm trying to deploy a symfony app to a VPS.
I deployed the code from git ok, I installed vendors and check /web/config.php to fix all the major and recommended issues on Symfony requirements. It's all green.
However, when I try to access the [VPS_IP]/my_project/web/app.php I get a page isn't working. [my_ip] is currently unable to handle the request.
I also tried to configure virtual host and try to access my Symfony app on the [my_ip] only as URL address and I get the same result.
I've enabled apache 2 mod rewrite, I've added and enabled all the necessary php extensions, I've set date.timezone in php.ini, I've also looked in the dev.log files and tehre I have this error which may be the cause:
[2016-11-22 14:45:49] php.DEBUG: fsockopen(): unable to connect to 127.0.0.1:800 0 (Connection refused) {"type":2,"file":"/var/www/html/giftbundle/vendor/symfony /symfony/src/Symfony/Bundle/FrameworkBundle/Command/ServerCommand.php","line":59 ,"level":28928} []
Could anyone provide some help?
config.yml
imports:
- { resource: parameters.yml }
- { resource: security.yml }
- { resource: services.yml }
- { resource: "#MyVendorBundle/Resources/config/services.yml" }
# Put parameters here that don't need to change on each machine where the app is deployed
# http://symfony.com/doc/current/best_practices/configuration.html#application-related-configuration
parameters:
locale: en
framework:
#esi: ~
#translator: { fallbacks: ["%locale%"] }
secret: "%secret%"
router:
resource: "%kernel.root_dir%/config/routing.yml"
strict_requirements: ~
form: ~
csrf_protection: ~
validation: { enable_annotations: true }
serializer: { enable_annotations: true }
templating:
engines: ['twig']
#assets_version: SomeVersionScheme
default_locale: "%locale%"
trusted_hosts: ~
trusted_proxies: ~
session:
# handler_id set to null will use default session handler from php.ini
handler_id: ~
save_path: "%kernel.root_dir%/../var/sessions/%kernel.environment%"
fragments: ~
http_method_override: true
assets: ~
# Twig Configuration
twig:
debug: "%kernel.debug%"
strict_variables: "%kernel.debug%"
form_themes:
- 'bootstrap_3_layout.html.twig'
# Doctrine Configuration
doctrine:
dbal:
driver: pdo_mysql
host: "%database_host%"
port: "%database_port%"
dbname: "%database_name%"
user: "%database_user%"
password: "%database_password%"
charset: UTF8
# if using pdo_sqlite as your database driver:
# 1. add the path in parameters.yml
# e.g. database_path: "%kernel.root_dir%/data/data.db3"
# 2. Uncomment database_path in parameters.yml.dist
# 3. Uncomment next line:
# path: "%database_path%"
orm:
auto_generate_proxy_classes: "%kernel.debug%"
naming_strategy: doctrine.orm.naming_strategy.underscore
auto_mapping: true
# Swiftmailer Configuration
swiftmailer:
transport: "%mailer_transport%"
host: "%mailer_host%"
username: "%mailer_user%"
password: "%mailer_password%"
spool: { type: memory }
# app/config/config.yml
#knp_menu:
# use "twig: false" to disable the Twig extension and the TwigRenderer
# twig:
# template: knp_menu.html.twig
# if true, enables the helper for PHP templates
# templating: false
# the renderer to use, list is also available by default
# default_renderer: twig
assetic:
debug: '%kernel.debug%'
use_controller: '%kernel.debug%'
filters:
cssrewrite: ~
gregwar_captcha: ~
liip_imagine:
filter_sets:
cover_filter:
filters:
thumbnail:
size: [600, 400]
mode: inset
prod_thumbnail:
filters:
thumbnail:
size: [50, 50]
mode: inset
#web_profiler:
# toolbar: true
# position: bottom
# intercept_redirects: false
# excluded_ajax_paths: ^/bundles|^/_wdt
parameters.yml
# This file is auto-generated during the composer install
parameters:
database_host: [another remote DB IP]
database_port: 3306
database_name: [remote DB name]
database_user: [Remote DB user]
database_password: [remote DB PSW]
mailer_transport: sendmail
mailer_host: 127.0.0.1
mailer_user: null
mailer_password: null
secret: rodacsoft
facebook_app_id: [fb_app_ID]
facebook_app_secret: [fb_secret]
VPS /etc/apache2/sites-available/000-default.conf
<VirtualHost *:80>
DocumentRoot /var/www/html/giftbundle/web
<Directory /var/www/html/giftbundle/web>
AllowOverride None
Order Allow,Deny
Allow from All
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ app.php [QSA,L]
</IfModule>
</Directory>
# uncomment the following lines if you install assets as symlinks
# or run into problems when compiling LESS/Sass/CoffeScript assets
# <Directory /var/www/project>
# Options FollowSymlinks
# </Directory>
ErrorLog /var/log/apache2/symfony_error.log
CustomLog /var/log/apache2/symfony_access.log combined
</VirtualHost>
EDIT: in the Symfony_error.log I have this. No clue how to fix it or if it's related.
[Tue Nov 22 14:46:06.216187 2016] [:error] [pid 21788] [client 159.153.60.77:18035] PHP Fatal error: Uncaught Symfony\\Component\\DependencyInjection\\Exception\\ServiceNotFoundException: The service "validator.builder" has a dependency on a non-existent service "validator.mapping.cache.apc". in /var/www/html/giftbundle/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Compiler/CheckExceptionOnInvalidReferenceBehaviorPass.php:58\nStack trace:\n#0 /var/www/html/giftbundle/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Compiler/CheckExceptionOnInvalidReferenceBehaviorPass.php(51): Symfony\\Component\\DependencyInjection\\Compiler\\CheckExceptionOnInvalidReferenceBehaviorPass->processReferences(Array)\n#1 /var/www/html/giftbundle/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Compiler/CheckExceptionOnInvalidReferenceBehaviorPass.php(51): Symfony\\Component\\DependencyInjection\\Compiler\\CheckExceptionOnInvalidReferenceBehaviorPass->processReferences(Array)\n#2 /var/www/html/giftbundle/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Compiler/CheckExceptionOnIn in /var/www/html/giftbundle/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Compiler/CheckExceptionOnInvalidReferenceBehaviorPass.php on line 58
Check if cache folder is writable by apache (www-data) user. You cannot access [VPS_IP]/my_project/web/app.php because you already defined web/ folder as root folder in apache config. You should define ServerName and ServerAlias in apache config with your domain name or try direct access to [VPS_IP]/app.php.
Also enter your IP to app_dev and access [VPS_IP]/app_dev.php for more clear errors.
I'm trying to create database through doctrine.
php app/console doctrine:database:create
When I run the command above, I receive the following errors:
[Doctrine\DBAL\Exception\ConnectionException]
An exception occured in driver: SQLSTATE[HY000] [2002] Connection refused
[Doctrine\DBAL\Driver\PDOException]
SQLSTATE[HY000] [2002] Connection refused
[PDOException]
SQLSTATE[HY000] [2002] Connection refused
What I have tried
This symbolic link creation did not work for me.
sudo ln -s /Applications/MAMP/tmp/mysql/mysql.sock mysql.sock
I've tried with both
database_host: localhost and database_host: 127.0.0.1 nothing changed.
I know that my MySQL port is 8889 as I can see on MAMP.
I could not check the option Allow network access to MySQL under MySQL tab on MAMP since I do not have MAMP Pro
Here are my configuration files
config.yml
imports:
- { resource: parameters.yml }
- { resource: security.yml }
- { resource: services.yml }
- { resource: "#FatihTestBundle/Resources/config/services.yml" }
# Put parameters here that don't need to change on each machine where the app is deployed
# http://symfony.com/doc/current/best_practices/configuration.html#application-related-configuration
parameters:
locale: en
framework:
#esi: ~
#translator: { fallbacks: ["%locale%"] }
secret: "%secret%"
router:
resource: "%kernel.root_dir%/config/routing.yml"
strict_requirements: ~
form: ~
csrf_protection: ~
validation: { enable_annotations: true }
#serializer: { enable_annotations: true }
templating:
engines: ['twig']
default_locale: "%locale%"
trusted_hosts: ~
trusted_proxies: ~
session:
# handler_id set to null will use default session handler from php.ini
handler_id: ~
fragments: ~
http_method_override: true
# Twig Configuration
twig:
debug: "%kernel.debug%"
strict_variables: "%kernel.debug%"
cache: false
# Doctrine Configuration
doctrine:
dbal:
driver: pdo_mysql
host: "%database_host%"
port: "%database_port%"
dbname: "%database_name%"
user: "%database_user%"
password: "%database_password%"
charset: UTF8
# if using pdo_sqlite as your database driver:
# 1. add the path in parameters.yml
# e.g. database_path: "%kernel.root_dir%/data/data.db3"
# 2. Uncomment database_path in parameters.yml.dist
# 3. Uncomment next line:
# path: "%database_path%"
orm:
auto_generate_proxy_classes: "%kernel.debug%"
naming_strategy: doctrine.orm.naming_strategy.underscore
auto_mapping: true
# Swiftmailer Configuration
swiftmailer:
transport: "%mailer_transport%"
host: "%mailer_host%"
username: "%mailer_user%"
password: "%mailer_password%"
spool: { type: memory }
parameters.yml:
# This file is auto-generated during the composer install
parameters:
database_host: localhost
database_port: 8889
database_name: todo
database_user: root
database_password: root
mailer_transport: smtp
mailer_host: 127.0.0.1
mailer_user: null
mailer_password: null
secret: fgnfgmngfm
php app/console cache:clear
The problem was because of cache, I received error messages not matter what I did. The command above that clears the cache and
changing the database port to 3306 in both MAMP and paramteters.yml has solved the problem.
Check your DNS settings. If you are not using a VPN, turn it off.
You can test the connection with "Sequel PRO"
Hostname : localhost - 127.0.0.1 - IP Adress
Password : 1234 - root
If they do not solve the problem check the user permissions.
mysql database -> user table
Hi I stumble upon this error everytime I want to run my Symfony application from console. Therefore I am unable to use this symphony app at all. Please help me with your knowledge.
[Symfony\Component\Config\Exception\FileLoaderLoadException]
Unable to parse at line 9 (near "mailer_transport="gmail"") in
/opt/lampp/htdocs/symblog.dev/app/config/parameters.yml (which is
being imported from
"/opt/lampp/htdocs/symblog.dev/app/config/config.yml").
[Symfony\Component\Yaml\Exception\ParseException]
Unable to parse at line 9 (near "mailer_transport="gmail"").
Here is my /app/config/parameters.yml file (I have my true password in original file obviously)
parameters:
database_driver: pdo_mysql
database_host: 127.0.0.1
database_port: null
database_name: symblog_db
database_user: root
database_password: null
mailer_transport="gmail"
mailer_encryption="ssl"
mailer_auth_mode="login"
mailer_host="smtp.gmail.com"
mailer_user="mactestsymblog#gmail.com"
mailer_password="xxxxxxxxx"
secret: JaTylkoTrenuje
And my app/config/config.yml file
imports:
- { resource: parameters.yml }
- { resource: security.yml }
- { resource: services.yml }
- { resource: #BloggerBlogBundle/Resources/config/config.yml }
# Put parameters here that don't need to change on each machine where the app is deployed
# http://symfony.com/doc/current/best_practices/configuration.html#application-related-configuration
parameters:
locale: en
framework:
#esi: ~
#translator: { fallbacks: ["%locale%"] }
secret: "%secret%"
router:
resource: "%kernel.root_dir%/config/routing.yml"
strict_requirements: ~
form: ~
csrf_protection: ~
validation: { enable_annotations: true }
#serializer: { enable_annotations: true }
templating:
engines: ['twig']
#assets_version: SomeVersionScheme
default_locale: "%locale%"
trusted_hosts: ~
trusted_proxies: ~
session:
# handler_id set to null will use default session handler from php.ini
handler_id: ~
fragments: ~
http_method_override: true
# Twig Configuration
twig:
debug: "%kernel.debug%"
strict_variables: "%kernel.debug%"
# Assetic Configuration
assetic:
debug: "%kernel.debug%"
use_controller: false
bundles: [ ]
#java: /usr/bin/java
filters:
cssrewrite: ~
#closure:
# jar: "%kernel.root_dir%/Resources/java/compiler.jar"
#yui_css:
# jar: "%kernel.root_dir%/Resources/java/yuicompressor-2.4.7.jar"
# Doctrine Configuration
doctrine:
dbal:
driver: pdo_mysql
host: "%database_host%"
port: "%database_port%"
dbname: "%database_name%"
user: "%database_user%"
password: "%database_password%"
charset: UTF8
# if using pdo_sqlite as your database driver:
# 1. add the path in parameters.yml
# e.g. database_path: "%kernel.root_dir%/data/data.db3"
# 2. Uncomment database_path in parameters.yml.dist
# 3. Uncomment next line:
# path: "%database_path%"
orm:
auto_generate_proxy_classes: "%kernel.debug%"
naming_strategy: doctrine.orm.naming_strategy.underscore
auto_mapping: true
# Swiftmailer Configuration
swiftmailer:
transport: "%mailer_transport%"
host: "%mailer_host%"
username: "%mailer_user%"
password: "%mailer_password%"
spool: { type: memory }
As noted by redbirdo, you have = instead of : in your parameters.yml, which should be like this:
parameters:
database_driver: pdo_mysql
database_host: 127.0.0.1
database_port: null
database_name: symblog_db
database_user: root
database_password: null
mailer_transport: "gmail"
mailer_encryption: "ssl"
mailer_auth_mode: "login"
mailer_host: "smtp.gmail.com"
mailer_user: "mactestsymblog#gmail.com"
mailer_password: "xxxxxxxxx"
secret: JaTylkoTrenuje
I've a problem with symfony.
When I try to run this command :
php app/console doctrine:schema:update --force
And I've error:
[PDOException]
SQLSTATE[HY000] [2002] Connection refused
Here is my config.yml
imports:
- { resource: parameters.yml }
- { resource: security.yml }
- { resource: services.yml }
framework:
#esi: ~
#translator: { fallback: "%locale%" }
secret: "%secret%"
router:
resource: "%kernel.root_dir%/config/routing.yml"
strict_requirements: ~
form: ~
csrf_protection: ~
validation: { enable_annotations: true }
templating:
engines: ['twig']
#assets_version: SomeVersionScheme
default_locale: "%locale%"
trusted_hosts: ~
trusted_proxies: ~
session:
# handler_id set to null will use default session handler from php.ini
handler_id: ~
fragments: ~
http_method_override: true
# Twig Configuration
twig:
debug: "%kernel.debug%"
strict_variables: "%kernel.debug%"
# Assetic Configuration
assetic:
debug: "%kernel.debug%"
use_controller: false
bundles: [ ]
#java: /usr/bin/java
filters:
cssrewrite: ~
#closure:
# jar: "%kernel.root_dir%/Resources/java/compiler.jar"
#yui_css:
# jar: "%kernel.root_dir%/Resources/java/yuicompressor-2.4.7.jar"
# Doctrine Configuration
doctrine:
dbal:
driver: "%database_driver%"
host: "%database_host%"
port: "%database_port%"
dbname: "%database_name%"
user: "%database_user%"
password: "%database_password%"
charset: UTF8
unix_socket: /tmp/mysql.sock
# if using pdo_sqlite as your database driver:
# 1. add the path in parameters.yml
# e.g. database_path: "%kernel.root_dir%/data/data.db3"
# 2. Uncomment database_path in parameters.yml.dist
# 3. Uncomment next line:
# path: "%database_path%"
orm:
auto_generate_proxy_classes: "%kernel.debug%"
auto_mapping: true
# Swiftmailer Configuration
swiftmailer:
transport: "%mailer_transport%"
host: "%mailer_host%"
username: "%mailer_user%"
password: "%mailer_password%"
spool: { type: memory }
And my parameters.yml
parameters:
database_driver: pdo_mysql
database_host: 127.0.0.1
database_port: '8889'
database_name: sil19
database_user: root
database_password: root
mailer_transport: smtp
mailer_host: 127.0.0.1
mailer_user: null
mailer_password: null
locale: en
secret: e7f97888e382ddd2e235dc7da6fc39346b37096c
database_path: null
I don't know where the problem is from. So if someone have any idea. Thanks in advance
I'had to check "Allow network access to Mysql" to make it work on MAMP.
I'have got the same error when trying to connect SYMFONY 4 to MAMP Mysql:
An exception occurred in driver: SQLSTATE[HY000] [2002] Connection refused
For my case, it was a wrong Mysql port, just changed 3306 to 8889 to fix it
DATABASE_URL=mysql://root:root#127.0.0.1:8889/db_name
in my .env file
Run at the full path, like this:
/Applications/MAMP/bin/php/php5.4.4/bin/php bin/console
On Unix, MySQL programs treat the host name localhost specially, in a way that is likely different from what you expect compared to other network-based programs. For connections to localhost, MySQL programs attempt to connect to the local server by using a Unix socket file. This occurs even if a --port or -P option is given to specify a port number. To ensure that the client makes a TCP/IP connection to the local server, use --host or -h to specify a host name value of 127.0.0.1, or the IP address or name of the local server. You can also specify the connection protocol explicitly, even for localhost, by using the
https://blog.liplex.de/symfony-console-connection-refused-with-mamp/