What is PostgreSQL?
A database is a place that stores data in an organised way, in tables. A table is like a spreadsheet page. PostgreSQL, often called Postgres, is a kind of database software. Some apps need it instead of MySQL.
A new database starts empty. You then add tables, or an app adds them for you.
Method 1: cPanel
- Log in to cPanel.
- In the Databases section, click PostgreSQL Databases.
- Under Create New Database, type a name.
- Click Create Database.
- Click Go Back when you see the success message.
cPanel adds your account name before the name, like account_mydb. Write down the full name. You need it later.
You must also make a user and link it to the database. Otherwise, your app cannot log in. In the same page, use PostgreSQL Users and Add a User To a Database.
If you do not see PostgreSQL Databases, it may not be on your plan. Ask Hostvento support.
Method 2: Command line (root access)
This is for VPS and dedicated server owners who have root access. Root access means full control of the server.
- Connect with SSH.
- Switch to the postgres user.
su - postgres
This changes you to the user that manages PostgreSQL.
- Create the database.
createdb mydb
This makes a database named mydb.
- Check that it exists.
psql -l
This lists all databases.
You can also do it inside psql with SQL:
CREATE DATABASE mydb;
Warning: Do not use a name that already exists. Never run DROP DATABASE unless you have a backup. It deletes the database for good.
Quick recap
- PostgreSQL is a database type, like MySQL.
- In cPanel use PostgreSQL Databases and Create Database.
- cPanel adds a prefix to the name. Note the full name.
- Create a user and link it to the database.
- On a server with root, use
createdb.