User and Database Management
This document provides a guide to creating and managing databases and users in your on-demand database environment. It covers both MySQL and PostgreSQL databases.
Prerequisites
-
Create a database in Cockpit and note the connection details (FQDN, username, and password).
-
MySQL and PostgreSQL command line interface tools are required to follow this article.
MySQL
Connecting to your Database:
mysql -h FQDN -u dbadmin -p
Creating a new database named app_prod
:
mysql> CREATE DATABASE app_prod;
Creating a new user named app_prod
:
mysql> CREATE USER 'app_prod' IDENTIFIED BY 'strongpassword';
Granting the user app_prod
privileges to the database app_prod
:
mysql> GRANT ALL ON app_prod.* TO 'app_prod'@'%';
For granting more specified privileges, find the details in the official MySQL documentation: Summary of Available Privileges
Changing the user app_prod
's password:
mysql> ALTER USER app_prod IDENTIFIED BY 'newstrongpassword';
Deleting the database app_prod
:
mysql> DROP DATABASE app_prod;
Deleting the user app_prod
:
mysql> DROP USER app_prod;
Use the official MySQL documentation for additional info about user and database management.
PostgreSQL
Conneting to your Database:
psql -h FQDN -d postgres -U dbadmin
# at first you can use the default database 'postgres' to be able to connect.
Creating a new database named app_prod
:
postgres=> CREATE DATABASE app_prod;
Creating a new user named app_prod
:
postgres=> CREATE USER app_prod WITH PASSWORD 'strongpassword';
Granting the user app_prod
privileges to the database app_prod
:
postgres=> GRANT ALL ON app_prod TO app_prod;
For granting more specified privileges, find the details in the official postgres documentation: DDL privileges.
Changing the user app_prod
's password:
postgres=> ALTER USER app_prod WITH PASSWORD 'newstrongpassword';
Deleting the database app_prod
:
postgres=> DROP DATABASE app_prod;
Deleting the user app_prod
:
postgres=> DROP USER app_prod;
Use the official Postgres documentation for additional info about user and database management.