Skip to content

Managing MySQL databases

Using the Dashboard

You can manage MySQL databases using the Databases page in the dashboard. Here you'll find a list of your MySQL databases.

DB list

To add a new database, simply click the "Create Database" link in the top right corner of the dashboard.

Create database

You will be prompted for a database name, username and password. The username and password will be automatically generated if left blank.

Once created, you will see the new database details displayed to you.

Database

MySQL passwords are not shown

We do not display MySQL passwords by default- you can click the icon next to the password field to copy it to your clipboard. If you lose access to a MySQL password you'll need to reset it via PHPMyAdmin.

Cloning databases

It can be useful to clone a MySQL database, for example if you need a copy of it for testing purposes. Cloning a database generates a new MySQL user. Existing grants and privileges are not copied.

To clone a MySQL database, click the Clone icon in the actions menu on the databases page.

Database

You'll need to specify a new username and password for the MySQL user, as well as a new name for the database.

Once done, click Clone to start the process. Large databases may take a few moments to complete.

Database

Resetting MySQL credentials

If you've forgotten your MySQL password, you can reset it using the Reset Password option on the database page. To do this, click the Key icon in the actions menu.

Database

You will be prompted to enter and confirm a new password.

Using PHPMyAdmin

We understand some customers may wish to use the 'PHPMyAdmin' utility to manage their databases graphically. PHPMyAdmin is accessible from the "Tools" section of the left navigation menu.

Using the CLI

To view your databases, simply run the psmysql command. Your databases are listed, as per the example below:

cito~ # psmysql

[+] MySQL databases on this server:

+----------+
| Database |
+----------+
| testdb   |
+----------+

[+] MySQL users on this server:

+----------+-----------------+
| Username | Connection Host |
+----------+-----------------+
| testuser | localhost       |
+----------+-----------------+

To create a new MySQL database in Cito, use: psmysql -n <db name>  -u <username> -p <password>

To delete a MySQL database, use: psmysql -d <dbname>

Adding a new database

Invoke psmysql with the required arguments

A note on credentials

Databases are accessed using a set of credentials for each user. Note these are not the same as the system user password- instead, they are generated the first time you create a database owned by that user.

If you do not specify a username and password with the -u or -p flags this will be automatically generated for you.

cito~ # psmysql -n testdb -u testuser
[+] Created MySQL database testdb with user testuser
[+] Created user testuser with password QNOCh2UlfXu5YJziyUfkWr
[+] Please make a note of the MySQL password as it will not be shown again.

If the MySQL user for the specified owner already exists, it will not be modified.

Accessing the MySQL command line

You can also perform common MySQL operations at the MySQL command line. You must be logged in as admin to do this.

Importing data from a SQL dump

You may wish to import MySQL data into a newly-created database, using a .sql file created using mysqldump or similar.

To do this, issue the following as the admin user.

mysql <dbname> < export.sql

Substitute <dbname> for the database name and export.sql for the filename of your MySQL data.

Remote MySQL database access

For security purposes, remote access to MySQL is disallowed by default. Please contact support if you need to remotely connect to MySQL using a tool such as MySQL workbench or HeidiSQL.

Resetting a MySQL user password

This can be done using either the MySQL CLI or PHPMyAdmin:

Using PHPMyAdmin

  • Login to phpMyAdmin using the details above.
  • Click the "User accounts" tab in the main navigation
  • Find the user and click the "Edit privileges" icon
  • Under "Change password" section, select "Use text field" and enter a new password. Select "Go" to save the changes.

Using MySQL command line

ALTER USER 'username'@'localhost' IDENTIFIED BY 'new_password';

Substitute username for the username in the Databases page.