I cannot succeed in creating a database with Symfony throught the terminal
(I use a MAC and MAMP)
The line in the Terminal
MacBook-Pro-de-XXX:Symfony XXX$ php app/console doctrine:database:create
The answer I got in Terminal
Warning: PDO::__construct(): MySQL server has gone away in /Applications/MAMP/htdocs/Symfony/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php on line 40
Warning: PDO::__construct(): Error while reading greeting packet. PID=52773 in /Applications/MAMP/htdocs/Symfony/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php on line 40
Could not create database for connection named `symfony`
SQLSTATE[HY000] [2006] MySQL server has gone away
Here some other information that might help you help me to find where the probleme come from
the parameters.yml file in Symfony/app/config
# This file is auto-generated during the composer install
parameters:
database_driver: pdo_mysql
database_host: localhost:8888
database_port: null
database_name: symfony
database_user: root
database_password: root
mailer_transport: smtp
mailer_host: 127.0.0.1
mailer_user: null
mailer_password: null
locale: en
secret: ThisTokenIsNotSoSecretChangeIt
modify your host. if you have running mySql service on port 8888 your configuration should be as
database_host: localhost
database_port: 8888
if your mysql running on default port, use below configuration
database_host: localhost
database_port: null
hope this helps.
sorry for my bad english.
Make sure that the MySQL server is actually running. Also the MAMP default port for MySQL is 3306 and not 8888.
database_host: localhost
database_port: 3306
Related
I've executed
php bin/console doctrine:database:create
to create the project's datbabase andI get this error
Failed loading /opt/lampp/lib/php/extensions/no-debug-non-zts-20180731/xdebug.so: /opt/lampp/lib/php/extensions/no-debug-non-zts-20180731/xdebug.so: cannot open shared object file: No such file or directory
In AbstractMySQLDriver.php line 115:
An exception occured in driver: could not find driver
In PDOConnection.php line 47:
could not find driver
In PDOConnection.php line 43:
could not find driver
I'm using xampp on ubuntu and this is the config file of symfony
# This file is auto-generated during the composer install
parameters:
database_host: 127.0.0.1
database_port: 3306
database_name: mydb
database_user: root
database_password: 12345
mailer_transport: smtp
mailer_host: 127.0.0.1
mailer_user: null
mailer_password: null
secret: 55c7fcc15002180af1c4f7ad79dc62cfe6dfd91e
I'dont know what is wrong
I think the driver is not configured in your parameter, so let's add it like :
parameters:
database_driver: pdo_mysql # <== you can change it in your driver database
database_host: 127.0.0.1
database_port: 3306
database_name: mydb
database_user: root
database_password: 12345
mailer_transport: smtp
mailer_host: 127.0.0.1
mailer_user: null
mailer_password: null
secret: 55c7fcc15002180af1c4f7ad79dc62cfe6dfd91e
NB: you can check all driver available in your terminal like this:
php -m
and normally it must display you the extension driver you need like :
.......
PDO
pdo_dblib
pdo_mysql
PDO_ODBC
pdo_pgsql
pdo_sqlite
pgsql
.......
thanks, I hope it's help you
I have problem because I don't have create database
My parameters.yml
parameters:
database_host: 127.0.0.1
database_port: null
database_name: symfony
database_user: root
database_password: null
mailer_transport: smtp
mailer_host: 127.0.0.1
mailer_user: null
mailer_password: null
secret: ThisTokenIsNotSoSecretChangeIt
Help me, please :)
You need to start your Mysql service,and check if the apche service is listing to 127.0.0.1.
Then just open you CLI, then type:
php bin/console doctrine:database:drop --force
php bin/console doctrine:database:create
php bin/console doctrine:schema:update --force
Perhaps not created directory in which you are trying to create a database.
I'm trying to connect my symfony 2 application to an SQL SERVER database, everything works fine using SQL SERVER internal account but i need to avoid this by connecting my application throught a Windows account (for example using the windows user that runs the apache service on the web serveur).
Any idea ?
I tried to comment the user/password parameter
This file is auto-generated during the composer install
parameters:
database_driver: pdo_sqlsrv
# database_host: xxxxx
database_host: x.x.x.x
database_port: 1557
database_name: xxxxxx
# database_user: xxxxx
# database_password: "xxxxx"
But i got this error :
Fatal error: Uncaught exception
'Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException'
enter code here
with message 'You have requested a non-existent parameter "database_user".
Did you mean one of these: "database_driver", "database_host",
"database_port", "database_name"?' in ...
I found the solution : Just leave database_user and database_password to null :
database_user: null
database_password: null
I'm following the Symfony book and arrived at the chapter on dealing with the database. I have a few questions, and can't seem to find an answer.
I'm just following the parameters.yml file that I have looks like this (auto-generated)
parameters:
database_driver: pdo_mysql
database_host: 127.0.0.1
database_port: null
database_name: myproject
database_user: root
database_password: null
mailer_transport: smtp
mailer_host: 127.0.0.1
mailer_user: null
mailer_password: null
locale: en
secret: ThisTokenIsNotSoSecretChangeIt
debug_toolbar: true
debug_redirects: false
use_assetic_controller: true
Then I head over to the terminal and enter:
php app/console doctrine:database:create
I receive the following error:
Could not create database for connection named `myproject`
SQLSTATE[HY000] [2002] Connection refused
I have a few questions:
How do I fix this
Where is the database server? Did it come when I installed Symfony2 with Composer?
After a long search I found it. It had something to do with the mysql.default_socket as pointed out in the comments.
MAMP showed me the socket was
':/Applications/MAMP/tmp/mysql/mysql.sock'
After doing some more searching, I found that the socket can be set in config.yml, here:
doctrine:
dbal:
driver: "%database_driver%"
[...]
unix_socket: "/Applications/MAMP/tmp/mysql/mysql.sock"
[...]
If the unix_socket line is not there, just add it. Then tried to execute the same command in Terminal, which gave this result:
Created database for connection named `myproject`
And the database was really created.
Symfony doesn't install mysql I assume you are working in a lamp stack.
If I remember well it happened to me once and I changed database_host: 127.0.0.1 to localhost and it worked well since.
I created an entity on symfony 2, and now I'm trying to create a database using the console command :
php app/console doctrine:database:create
and it generates this error :
Could not create database for connection named `symfony`
SQLSTATE[HY000] [2003] Can't connect to MySQL server on '127.0.0.1' (61)
My OS is Mac OS x , with MAMP
and my paramaters file is :
parameters:
database_driver: pdo_mysql
database_host: 127.0.0.1
database_port: null
database_name: symfony
database_user: root
database_password: null
mailer_transport: smtp
mailer_host: 127.0.0.1
mailer_user: null
mailer_password: null
locale: en
secret: ThisTokenIsNotSoSecretChangeIt
MySQL by default runs on port 3306. If you haven't changed that port then use:
database_port: 3306
If you have changed the port then use the changed port instead and give it a try.
What if you try to write this :
database_password: null > database_password: ''
Your user have the goods permissions ?