A database is essentially a data archive, comparable to the classic paper filing system. Information is stored in tables, which can be accessed and read in many different ways. Databases are valuable because they provide a structured and efficient way to store, organise, and retrieve information.
Unlike keeping data in simple files or spreadsheets, a database ensures that large amounts of information remain consistent, secure, and easy to manage.
Creating a database
Before you can access phpMyAdmin, you need to create a database.
1. Log in to DirectAdmin.
2. In the menu, go to 'Account Manager' → 'Databases'.
3. On this page, type your preferred name in the 'Create Database' field, then click 'Create'.
Advanced mode (optional)
By selecting advanced mode, you can set your own 'username' and 'password' for the database you are creating.
1. A confirmation message will now appear saying 'Database created', and the following details will be displayed:
- DB Name: The name you gave the database.
- DB User: The username of the created database.
- Password: The password for the created database.
You can use the data in a web application or to log in to phpMyAdmin:
https://yourdomain.com/phpmyadmin/
Replace yourdomain.com with your own domain.
Add and edit data
You can modify the data or records in your database using phpMyAdmin. You can access phpMyAdmin through DirectAdmin by going to Extra Features → phpMyAdmin, but the simplest method is to visit https://yourdomain.com/phpmyadmin in your browser. Just make sure to replace yourdomain.com with your own domain name.
Repair or optimise database
Databases can occasionally become corrupted, but in most cases a simple repair will fix the issue. They can also grow too large over time, so optimisation is advisable. Both repairs and optimisations can be carried out easily through DirectAdmin.
1. In the menu, go to 'Account Manager' → 'Databases'.
2. In the 'Databases List', locate the database you want to repair and click 'Manage' under the 'Actions' column.
3. At the bottom of the page, under 'Database Operations', click 'Repair' to fix the database, or 'Optimise' to improve its performance.
Users
When several scripts access the same database, it is advisable to assign multiple users to it. If one script becomes compromised, you can simply remove the affected user to contain the damage.
Create a user
Creating a user in DirectAdmin is easy.
1. In the menu, go to 'Account Manager' → 'Databases'.
2. In the 'Databases List', locate the database you want to add a user to and click 'Manage' under the 'Actions' column.
3. Click on 'Manage Users' at the top of the page.
4. On the following page, enter a username and password under 'Add User' and click 'Create'.
Change database password
It is also possible to change the password of a database user.
1. In the menu, go to 'Account Manager' → 'Databases'.
2. In the 'Databases List', locate the database you want to change the password for and click 'Manage' under the 'Actions' column.
3. Click on 'Manage Users' at the top of the page.
4. Enter the new password in the 'Password Manager' section and click on 'Change Password'.
Change permissions
Each database user is assigned specific rights, such as deleting tables or adding records. It is recommended that you do not grant a user more rights than necessary. You can adjust these rights in DirectAdmin as follows:
1. In the menu, go to 'Account Manager' → 'Databases'.
2. In the 'Databases List', locate the database you want to change the rights for and click 'Manage' under the 'Actions' column.
3. Click 'Privileges' next to the username, select or deselect the desired permissions, and then click 'Save Changes'.
Deleting users
To delete a user, follow these steps:
1. In the menu, go to 'Account Manager' → 'Databases'.
2. On the following page, select 'Manage Users'.
3. In the 'User Accounts' section, locate the user that you want to delete permanently and click 'Delete' under the 'Actions' column.
Hosts
You may want to access your database with a local program (e.g., Navicat) or from another website. For security reasons, this is blocked by default, but you can allow access by adding specific IP addresses—up to a maximum of 30.
Adding a host
1. In the menu, go to 'Account Manager' → 'Databases'.
2. In the 'Databases List', locate the database you want to add another IP address (host) to and click 'Manage' under the 'Actions' column.
3. In the 'User Accounts' section, locate the user that you want to add another IP address (host) to and click 'Manage' under the 'Actions' column.
4. Enter the IP address or hostname in the 'Allowed Hosts' field and click 'Add Host'. You can also enter a server name.
Deleting a host
To delete a host, follow these steps:
1. In the menu, go to 'Account Manager' → 'Databases'.
2. In the 'Databases List', locate the database from which you want to remove an IP address (host) and click 'Manage' under the 'Actions' column.
3. In the 'User Accounts' section, locate the user from which you want to remove an IP address (host) and click 'Manage' under the 'Actions' column.
4. Click the 'Remove' button behind the IP address (host) to remove it.