Outils pour utilisateurs

Outils du site


pgsql-create-db-user:postgresql_create_database_user

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentesRévision précédente
Prochaine révision
Révision précédente
pgsql-create-db-user:postgresql_create_database_user [2019/01/11 16:01] rguyaderpgsql-create-db-user:postgresql_create_database_user [2023/05/23 08:56] (Version actuelle) – [Autoriser les connections authentifiées en local pour posgresql] ghusson
Ligne 4: Ligne 4:
  
 <code bash> <code bash>
-  # cp -a /etc/postgresql/9.4/main/pg_hba.conf /etc/postgresql/9.4/main/pg_hba.conf_ 
-  # sed -i "s/local all all peer/local all all md5/g" /etc/postgresql/9.4/main/pg_hba.conf 
-  # service postgresql stop 
-  # service postgresql start 
-</code> 
  
-  PGSQL_DB_NAME=db_horde +export PGSQL_DB_NAME=db_mydbname 
-  PGSQL_USERNAME=hordeu +export PGSQL_USERNAME=myusername 
-  PGSQL_USERPWD=password+export PGSQL_USERPWD=mypassword 
 + 
 + 
 +apt install postgresql 
 +cp -a /etc/postgresql/13/main/pg_hba.conf /etc/postgresql/13/main/pg_hba.conf_ 
 +sed -i "s/local   all             all                                     peer/local   all             all                                     md5/g" /etc/postgresql/11/main/pg_hba.conf 
 +service postgresql stop 
 +service postgresql start 
 + 
 + 
 +cd / 
 +/bin/su postgres --command "/usr/bin/createuser --no-superuser --no-createdb --no-createrole --login ${PGSQL_USERNAME}" 
 +/bin/su postgres --command "/usr/bin/psql --command=\"ALTER USER ${PGSQL_USERNAME} PASSWORD '${PGSQL_USERPWD}'\"" 
 +/bin/su postgres --command "/usr/bin/createdb --encoding UTF8 --owner ${PGSQL_USERNAME} ${PGSQL_DB_NAME}" 
 +/bin/su postgres --command "/usr/bin/psql --command \"GRANT ALL PRIVILEGES ON DATABASE ${PGSQL_DB_NAME} to ${PGSQL_USERNAME}\""
  
-<code bash> 
-  /bin/su postgres --command "/usr/bin/createuser --no-superuser --no-createdb --no-createrole --login ${PGSQL_USERNAME}" 
-  /bin/su postgres --command "/usr/bin/psql --command=\"ALTER USER ${PGSQL_USERNAME} PASSWORD '${PGSQL_USERPWD}'\"" 
-  /bin/su postgres --command "/usr/bin/createdb --encoding UTF8 --owner ${PGSQL_USERNAME} ${PGSQL_DB_NAME}" 
-  /bin/su postgres --command "/usr/bin/psql --command \"GRANT ALL PRIVILEGES ON DATABASE ${PGSQL_DB_NAME} to ${PGSQL_USERNAME}\"" 
 </code> </code>
  
Ligne 45: Ligne 49:
 \q \q
 </code> </code>
 +
 +===== Cheat Sheets =====
 +  * http://www.ixany.org/docs/PostgreSQL_commandes_mysql.html
 +  * https://tomcam.github.io/postgres/
pgsql-create-db-user/postgresql_create_database_user.1547222494.txt.gz · Dernière modification : 2019/01/11 16:01 de rguyader