rake db:create encoding error with postgresql

前端 未结 5 875
日久生厌
日久生厌 2021-01-30 02:41

I\'m importing an existing rails project that I was working on into my new arch linux system, I already installed all gems and postgresql correctly, but I having some issues whe

5条回答
  •  旧时难觅i
    2021-01-30 02:53

    Similar to the other answers I found this gist to be very helpful. Using Ubuntu 14.04. I wanted to change the default template to use UTF-8.

    Get into the postgres prompt:

    Activate the postgres console.
    su - postgres
    psql
    

    Then type the following commands:

    # First, we need to drop template1. Templates can’t be dropped, so we first modify it so t’s an ordinary database:
    
            UPDATE pg_database SET datistemplate = FALSE WHERE datname = 'template1';
    
    # Now we can drop it:
    
            DROP DATABASE template1;
    
    # Now its time to create database from template0, with a new default encoding:
    
            CREATE DATABASE template1 WITH TEMPLATE = template0 ENCODING = 'UNICODE';
    
    # Now modify template1 so it’s actually a template:
    
            UPDATE pg_database SET datistemplate = TRUE WHERE datname = 'template1';
    
    # Now switch to template1 and VACUUM FREEZE the template:
    
            \c template1
    
            VACUUM FREEZE;
    

    Problem should be resolved. Credits to: https://gist.github.com/amolkhanorkar-webonise/8706915

提交回复
热议问题