Symfony3 Deploying issue PDOException “could not find driver” in php - php

Hey everyone am trying to deploy my symfony 3 app i uploaded the project files set up my vps 1&1 hosting on ubuntu 16.04 after i installed php , mysql , apache2 .
i tried to run command
php bin/console doctrine:schema:create
Error :
[Doctrine\DBAL\Exception\DriverException]
An exception occured in driver: could not find driver
[Doctrine\DBAL\Driver\PDOException]
could not find driver
[PDOException]
could not find driver
first i though it's maybe parameters problem but then i made some changes in my file parameters.ymllike this code below :
This file is auto-generated during the composer install
parameters:
database_host: 127.0.0.1
database_port: 3306
database_name: kuenstlerdienste
database_user: Test
database_password: xxxxx
mailer_transport: smtp
mailer_host: 127.0.0.1
mailer_user: null
mailer_password: null
secret: 40ea1d1efb058912e7ae152d2847c9834d97faa4
authentication.handler.login_success_handler.class: KuenstlerdiensteBundle\Security\LoginSuccessHandler
i don't think this is typo cause credentials are valid and when i enter mysql
after login am getting this result
mysql> Show DATABASES
-> ;
+--------------------+
| Database |
+--------------------+
| information_schema |
| kuenstlerdienste |
+--------------------+
2 rows in set (0.00 sec)
i also tested if pdo installed on my vps : by typing php -m and it was mentioned in the result PDO
i don't get it if it's symofony issue or in mysql config files there's somthing missing , thanks to any help

Try to use this to check if you have the module installed or not.
php -m | grep pdo
Expected something like:
pdo_mysql

Related

Connect Symfony 2 application to SQL SERVER using windows account

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

Symfony2 database configuration during deployment

hi i'm new to symfony2 web development. I have develop a sample symfony2 application with a database on my localhost. It is working fine on my localhost.
I have uploaded my project to web server, All the files are working on the web server other than the files connecting with databases. When I requested for the files that are connected with database I got these errors.
Warning: PDO::__construct(): MySQL server has gone away in
/home/pipeline/public_html/BusinessPipeline/BusinessPipeline/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php
on line 40
Warning: PDO::__construct(): Error while reading greeting packet.
PID=18547 in
/home/pipeline/public_html/BusinessPipeline/BusinessPipeline/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php
on line 40
I have setup the parameters.yml file as follows.
# app/config/parameters.yml
parameters:
database_driver: pdo_mysql
database_host: localhost
database_name: test_project
database_user: my_username
database_password: my_password
I didn't change anything rather than change the parameters.yml.
what can I do for this issue, do I need to do any configuration prior to deployment?
Thanks in advance
Check MySQL Server doc for specific problem about your error message:
B.5.2.9 MySQL server has gone away
Check the wait_timeout problem

Cannot create database with terminal doctrine:database:create

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

How do I set up a database for Symfony2 using Doctrine?

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.

Symfony2 Database Config

I've just inherited a Symfony2 project from a former co-worker. I'm trying to get it running locally, but am getting a SQLSTATE[HY000] [2002] Connection refused error. I guess I'm missing the database connection that I've read should be in the app/config/parameters.yml file.
Is there anyway of finding this information if all I have is the project and the live site?
If it's standard Symfony2 project you have to configure your database connection information in app/config/parameters.yml, like:
# app/config/parameters.yml
parameters:
database_driver: pdo_mysql
database_host: localhost
database_name: test_project
database_user: root
database_password: password
# ...
More in doc.
After that you have to create database:
$ php app/console doctrine:database:create
Next, create table schema:
$ php app/console doctrine:schema:update --force
Also, you could load (if your co-worker provided it ; ) some data fixtures, so try:
$ php app/console doctrine:fixtures:load
If your coworker doesn't use doctrine fixtures you should consider dumping data from your prod database.

Categories