/go/postgre manages PostgreSQL databases for GoAdmio hosting accounts. It is the PostgreSQL counterpart of mysql. It can: PostgreSQL must already be installed and running (see postgresql). Every admin action in GoAdmio has a matching /go/ command, so anything you can click you can also script.
Quick start
# Create the database "shop" with the user "shopuser" for example.com
/go/postgre example.com shop shopuser 'S3cureP@ss'
Options
This command has no options. It takes five positional arguments.
| Argument | Required | Notes |
|---|---|---|
<domain> |
Yes | The hosting account. When creating, the account must exist in GoAdmio and not be in the recycle bin. |
<database> |
Yes | The database name. Use lowercase letters, digits, and underscores, and start with a letter (see Names). |
<user> |
Yes | The PostgreSQL user. For delete, it is ignored (the stored user of the database is used). |
<password> |
Yes | The user’s password. For delete, it is ignored. See the placeholders below. |
<action> |
No | edit or delete. Any other value, or none, creates a database. The words are case-sensitive. |
Four placeholders in the password are replaced by the characters that are awkward to type in a shell:
| Placeholder | Becomes |
|---|---|
[DollarSign] |
$ |
[AndSign] |
& |
[EqualSign] |
= |
[HashSign] |
# |
A password that contains a single quote (') does not work, because the password is placed inside SQL quotes without escaping.
Security
[!WARNING]
- The password is logged. The command writes all of its arguments to
/var/log/go/postgre.log, so the password is stored there in plain text (with the placeholders still in place).- The password is also stored in plain text in GoAdmio’s PostgreSQL list (
/var/lib/sqlite/postgre.db), and it is visible in the process list while the command runs.- Remove old passwords from the log, and use a strong, unique password for each database user.
Examples
# Create a database and user
/go/postgre example.com shop shopuser 'S3cureP@ss'
# Password with special characters, using placeholders
/go/postgre example.com shop shopuser 'Pa[DollarSign]w0rd[HashSign]1'
# Change the password of the existing user
/go/postgre example.com shop shopuser 'NewP@ss1' edit
# Rename the user of a database
/go/postgre example.com shop newuser 'NewP@ss1' edit
# Delete a database (user and password are placeholders)
/go/postgre example.com shop - - delete
# List the databases and users that PostgreSQL has
sudo -i -u postgres psql -c "\l"
sudo -i -u postgres psql -c "\du"
Output
| Message | Meaning |
|---|---|
Database '<name>' created successfully. |
The create steps ran. This message is printed even if one of the PostgreSQL steps failed. |
Database '<name>' was successfully modified. |
The password of the existing user was changed (edit, same user). |
Database <name> deleted successfully... |
The delete steps ran. It is printed even if a step failed. |
Account <domain> not exists |
The domain is not a hosting account in GoAdmio, or it is in the recycle bin. Create only. |
Database '<name>' already exists. |
Another database with this name is already in GoAdmio’s list, for any account. Create only. |
Username '<user>' already exists. |
The user name is already taken. |
psql also prints its own result lines, such as CREATE ROLE, GRANT, ALTER DEFAULT PRIVILEGES, and DROP DATABASE, and any error. Read them: they are the real result of each step.
A rename (edit with a different user) and a delete for a database that isn’t in the list print no message of their own.
Every run is also recorded in /var/log/go/postgre.log.
See the full reference at /go/postgre and the GoAdmio command index.
GoAdmio is free and open source, with no license fees and no account limits. Read the GoAdmio docs, or see why it is a free cPanel alternative at goadmio.com.
