Advertisement
asanchez75

Linux/postgresql

Mar 5th, 2012
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. POSTGRES MANUAL
  2. =============================================================================================
  3. INSTALLATION
  4. =============================================================================================
  5. sudo apt-get install postgresql-9.1 postgresql-client-9.1 postgresql-contrib-9.1
  6. Now we need to reset the password for the ‘postgres’ admin account for the server
  7. sudo su postgres -c psql template1
  8. template1=# ALTER USER postgres WITH PASSWORD ‘password’;
  9. template1=# \q
  10. That alters the password for within the database, now we need to do the same for the unix user ‘postgres’:
  11. sudo passwd -d postgres
  12.  
  13. =============================================================================================
  14. asanchez75@ubuntu:/var/www$ sudo diff -u /etc/postgresql/9.1/main/postgresql.conf.backup /etc/postgresql/9.1/main/postgresql.conf
  15. --- /etc/postgresql/9.1/main/postgresql.conf.backup 2012-03-05 09:31:32.717231431 -0500
  16. +++ /etc/postgresql/9.1/main/postgresql.conf 2012-03-05 09:32:12.805230393 -0500
  17. @@ -56,7 +56,7 @@
  18.  
  19. # - Connection Settings -
  20.  
  21. -#listen_addresses = 'localhost' # what IP address(es) to listen on;
  22. +listen_addresses = '*' # what IP address(es) to listen on;
  23. # comma-separated list of addresses;
  24. # defaults to 'localhost', '*' = all
  25. # (change requires restart)
  26. @@ -81,7 +81,7 @@
  27. #ssl_ciphers = 'ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH' # allowed SSL ciphers
  28. # (change requires restart)
  29. #ssl_renegotiation_limit = 512MB # amount of data between renegotiations
  30. -#password_encryption = on
  31. +password_encryption = on
  32. #db_user_namespace = off
  33.  
  34. # Kerberos and GSSAPI
  35. =============================================================================================
  36. asanchez75@ubuntu:/var/www$ sudo diff -u /etc/postgresql/9.1/main/pg_hba.conf.backup /etc/postgresql/9.1/main/pg_hba.conf
  37. --- /etc/postgresql/9.1/main/pg_hba.conf.backup 2012-03-05 09:33:30.057228397 -0500
  38. +++ /etc/postgresql/9.1/main/pg_hba.conf 2012-03-05 10:28:29.713143070 -0500
  39. @@ -89,7 +89,7 @@
  40. # "local" is for Unix domain socket connections only
  41. local all all peer
  42. # IPv4 local connections:
  43. -host all all 127.0.0.1/32 md5
  44. +host all all 127.0.0.1/32 trust
  45. # IPv6 local connections:
  46. host all all ::1/128 md5
  47. # Allow replication connections from localhost, by a user with the
  48. @@ -97,3 +97,5 @@
  49. #local replication postgres peer
  50. #host replication postgres 127.0.0.1/32 md5
  51. #host replication postgres ::1/128 md5
  52. host all all xx.xxx.xxx.0/24 trust
  53. +
  54. +
  55. =============================================================================================
  56. LINKS FOR INSTALLATION
  57. =============================================================================================
  58. http://www.cyberciti.biz/faq/psql-fatal-ident-authentication-failed-for-user/
  59. http://www.ubuntugeek.com/howto-setup-database-server-with-postgresql-and-pgadmin3.html
  60. http://nixcraft.com/databases-servers/886-howto-list-display-databases-postgresql-pgsql-server.html
  61. =============================================================================================
  62. MIGRATING FROM MYSQL TO POSTGRESQL
  63. =============================================================================================
  64. http://onestoryeveryday.com/mysql-to-postgresql-conversionmigration.html
  65. https://github.com/tardate/mysql2postgres
  66.  
  67. Use this tool (first of all, install rubygems)
  68. gem install mysql2psql
  69.  
  70. Next, run script and within its current folder you will find
  71.  
  72. mysql2psql.yml
  73.  
  74. whose content should be something like
  75.  
  76. ----------------------------------------------------------------------------------------------
  77. mysql:
  78. hostname: localhost
  79. port: 3306
  80. socket: /var/run/mysqld/mysqld.sock
  81. username: root
  82. password: "123456"
  83. database: oldmtnforum
  84.  
  85. destination:
  86. # if file is given, output goes to file, else postgres
  87. file:
  88. postgres:
  89. hostname: localhost
  90. port: 5432
  91. username: postgres
  92. password: 123456
  93. database: oldmtnforum
  94.  
  95. # if tables is given, only the listed tables will be converted. leave empty to convert all tables.
  96. #tables:
  97. #- table1
  98. #- table2
  99. # if exclude_tables is given, exclude the listed tables from the conversion.
  100. #exclude_tables:
  101. #- table3
  102. #- table4
  103.  
  104.  
  105. # if supress_data is true, only the schema definition will be exported/migrated, and not the data
  106. supress_data: false
  107.  
  108. # if supress_ddl is true, only the data will be exported/imported, and not the schema
  109. supress_ddl: false
  110.  
  111. # if force_truncate is true, forces a table truncate before table loading
  112. force_truncate: false
  113.  
  114. ----------------------------------------------------------------------------------------------
  115. Be sure about your parameters, for example I use
  116. socket: /var/run/mysqld/mysqld.sock
  117. because I was using UBUNTU
  118.  
  119. ====================================
  120. LOGIN
  121. ====================================
  122.  
  123. su postgres (to log in as user named postgres)
  124. psql -d mydatabase (to lod directly to one database)
  125. psql (to enter to console and create data as user postgres)
  126.  
  127. =================================================================
  128. pg_dump
  129. =================================================================
  130. pg_dump oldmtnforum -U postgres -W -h localhost > oldmtnforum2.sql
  131. pg_dump bd_can -U postgres -W -h localhost | gzip -c > bd_can.sql.gz
  132. pg_dump --host localhost --port 5432 --username "postgres" --format tar --blobs --verbose --file "/home/asanchez75/Trash/oldmtnforum.psql" "oldmtnforum"
  133. =================================================================
  134. pg_restore
  135. =================================================================
  136. psql -U postgres -d test_can < /home/asanchez75/Trash/bd_can.sql
  137. pg_restore --host localhost --port 5432 --username "postgres" --dbname "test" --verbose "/home/asanchez75/Trash/oldmtnforum.psql"
  138.  
  139. =================================================================
  140. installation of pdo_pgsql
  141. =================================================================
  142.  
  143. http://cpanelforums.net/php-recompilation-errors/
  144.  
  145. checking for PostgreSQL support for PDO... yes, shared
  146. checking for pg_config... not found
  147. configure: error: Cannot find libpq-fe.h. Please specify correct PostgreSQL installation path
  148.  
  149. Fix:
  150. yum install postgresql-devel
  151.  
  152. =====================================
  153.  
  154. http://drupal.org.es/node/1649
  155.  
  156. Primero tienes que instalar el plugin para PDO
  157. Enviado por waspper el 15 Febrero, 2011 - 21:18.
  158.  
  159. En cuanto a PDO, verifica que tines instalado algo como esto:
  160. - php-pdo
  161. - php-pdo_pgsql
  162.  
  163. Los instalas, luego reinicias Apache y PostgreSQL asi:
  164. # su -
  165. # password:
  166. # service httpd restart
  167. # service postgresql restart
  168.  
  169. ====================================================================
  170. yum install postgresql-devel
  171. pecl install pdo_pgsql
  172.  
  173. ======================================================================
  174. working on SCHEMAS
  175.  
  176. template_postgis=# SET SEARCH_PATH TO "ecosistemas","$user","public";
  177. template_postgis=# SHOW SEARCH_PATH;
  178. \dn
  179.  
  180. ======================================================================
  181. check commands
  182.  
  183. execute \?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement