如何使用 Symfony 2.0 将数据库更改为 postgresql?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10588646/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 23:30:00 来源:igfitidea点击:
How to change a database to postgresql with Symfony 2.0?
提问by Benjamin Crouzier
回答by Benjamin Crouzier
Install postgresql under debian:
在 debian 下安装 postgresql:
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)
在/etc/php5/apache2/php.ini中,添加:(这实际上是可选的)
extension=pdo.so
extension=php_pdo_pgsql.so
Change the symfony apps/config/paramters.ini file:
更改 symfony apps/config/paramters.ini 文件:
[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