Advertisement
Guest User

Untitled

a guest
May 24th, 2015
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1. ======= Prolbem =================================================================================================================
  2. I have installed : ruby-2.0.0,postgres-9.2 , now in rails app when I execute:
  3.  
  4. rake db:create , command I get:
  5.  
  6. PG::InvalidParameterValue: ERROR: new encoding (UTF8) is incompatible with the encoding of the template database (SQL_ASCII)
  7. HINT: Use the same encoding as in the template database, or use template0 as template.
  8. : CREATE DATABASE "my_db_name" ENCODING = 'unicode'.......
  9.  
  10. bin/rake:16:in `load'
  11. bin/rake:16:in `<main>'
  12. Couldn't create database for {"adapter"=>"postgresql", "encoding"=>"unicode", "database"=>"my_db", "host"=>"localhost", "pool"=>5, "username" =>"my_user", "password"=>"my_password"}
  13.  
  14. =================================================================================================================================
  15.  
  16. Solution
  17.  
  18. =================================================================================================================================
  19.  
  20. Ok, below steps resolved the problem:
  21.  
  22. First, we need to drop template1. Templates can’t be dropped, so we first modify it so t’s an ordinary database:
  23.  
  24. UPDATE pg_database SET datistemplate = FALSE WHERE datname = 'template1';
  25.  
  26. Now we can drop it:
  27.  
  28. DROP DATABASE template1;
  29.  
  30. Now its time to create database from template0, with a new default encoding:
  31.  
  32. CREATE DATABASE template1 WITH TEMPLATE = template0 ENCODING = 'UNICODE';
  33.  
  34. Now modify template1 so it’s actually a template:
  35.  
  36. UPDATE pg_database SET datistemplate = TRUE WHERE datname = 'template1';
  37.  
  38. Now switch to template1 and VACUUM FREEZE the template:
  39.  
  40. \c template1
  41.  
  42. VACUUM FREEZE;
  43.  
  44. Problem should be resolved.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement