12

I have a Symfony2 project under Debian. What are the steps to change my database to postgresql ?

Note: The question has been asked here, but it is with symfony 1.4, I believe.

1

1 Answer 1

35

Install postgresql under debian:

apt-get install postgresql postgresql-client
apt-get install php5-pgsql
adduser mypguser
su - postgres
psql
CREATE USER mypguser WITH PASSWORD 'mypguserpass';
CREATE DATABASE mypgdatabase;
GRANT ALL PRIVILEGES ON DATABASE mypgdatabase to mypguser;
\q

In /etc/php5/apache2/php.ini, add: (this is in fact optional)

extension=pdo.so
extension=php_pdo_pgsql.so

Change the symfony apps/config/paramters.ini file:

[parameters]
    database_driver:    pdo_pgsql
    database_host:      localhost
    database_port:      null
    database_name:      mypgdatabase
    database_user:      mypguser
    database_password:  mypguserpass

Relaod your project:

php bin/vendors update
php app/console assets:install web
php app/console doctrine:schema:create
php app/console doctrine:fixtures:load
chmod 777 -R app/cache app/logs

You're done!

References:

Symfony documentation for configuring databases

Postgresql installation under debian

Sign up to request clarification or add additional context in comments.

2 Comments

shouldn't you tell postgres to run as mypguser? Or why are you doing adduser?
@Hendrik, you're right, there's no need to do the adduser.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.