> ## Documentation Index
> Fetch the complete documentation index at: https://help.onetsolutions.net/llms.txt
> Use this file to discover all available pages before exploring further.

# Databases

> Create MySQL databases and users, and manage them with phpMyAdmin

Most applications you install — WordPress, PrestaShop, Drupal — need a database. Creating one takes three steps in cPanel: the database itself, a user, and the link between them. Missing the third is the most common reason an installer fails.

<Info>
  **Prerequisites**

  * A Web Hosting service with OnetSolutions
  * Access to your cPanel account
</Info>

## Creating a Database

<Steps>
  <Step title="Log in to cPanel">
    Access your cPanel account through the OnetSolutions dashboard.
  </Step>

  <Step title="Open MySQL Databases">
    In the "Databases" section, click "MySQL Databases".
  </Step>

  <Step title="Create the database">
    Enter a name under "Create New Database" and click "Create Database". cPanel prefixes it with your account name, so `shop` becomes `username_shop` — the prefixed form is what your application needs.
  </Step>

  <Step title="Create a user">
    Scroll to "MySQL Users", enter a username and a strong password, then click "Create User". The username is prefixed the same way.
  </Step>

  <Step title="Link the user to the database">
    Under "Add User To Database", select the user and the database, click "Add", then grant "ALL PRIVILEGES" on the next screen.
  </Step>
</Steps>

<Warning>
  A database and a user are separate objects. Creating both without linking them leaves the application unable to connect, with an error that usually blames the password. If a fresh install refuses to connect, check this link first.
</Warning>

## Connection Settings

Use these values in your application's configuration:

| Setting       | Value                                  |
| ------------- | -------------------------------------- |
| Host          | `localhost`                            |
| Database name | `username_dbname`                      |
| Username      | `username_dbuser`                      |
| Password      | The one you set when creating the user |
| Port          | 3306                                   |

<Note>
  `localhost` is correct because the application and the database run on the same server. Remote connections are not open by default — an application hosted elsewhere cannot reach this database without additional configuration.
</Note>

## Using phpMyAdmin

phpMyAdmin is the web interface for inspecting and editing your data directly.

<Steps>
  <Step title="Open phpMyAdmin">
    In the "Databases" section of cPanel, click "phpMyAdmin". It opens already authenticated — there is no separate password.
  </Step>

  <Step title="Select your database">
    Pick it from the list on the left. Tables appear underneath.
  </Step>

  <Step title="Work on the data">
    Use "Browse" to read rows, "Search" to filter, and "SQL" to run a query.
  </Step>
</Steps>

<Warning>
  There is no undo in phpMyAdmin. A `DELETE` or `UPDATE` without a `WHERE` clause changes every row and cannot be reversed. Export the table before running anything you have not run before.
</Warning>

## Exporting and Importing

Export before any risky change, and to move a site between hosts.

<Steps>
  <Step title="Export">
    Select the database, open the "Export" tab, keep the "Quick" method and the SQL format, then click "Export". The file downloads to your computer.
  </Step>

  <Step title="Import">
    Select the target database, open the "Import" tab, choose your `.sql` file and click "Import".
  </Step>
</Steps>

<Note>
  Large imports can exceed the upload limit. If the file is too big, compress it to `.sql.gz` — phpMyAdmin accepts compressed dumps and the size drops considerably.
</Note>

## Troubleshooting

<AccordionGroup>
  <Accordion title="Error establishing a database connection">
    Check the four values in order: prefixed database name, prefixed username, password, and host set to `localhost`. Then confirm the user is actually linked to the database with privileges granted.
  </Accordion>

  <Accordion title="Access denied for user">
    Either the password is wrong, or the user has no privileges on that database. Re-adding the user to the database and granting ALL PRIVILEGES resolves the second case.
  </Accordion>

  <Accordion title="The import stops partway">
    Usually the file exceeds the upload or execution limit. Compress the dump, or split it into several files and import them in order.
  </Accordion>

  <Accordion title="Unknown database">
    The name is missing its prefix. `shop` does not exist; `username_shop` does.
  </Accordion>
</AccordionGroup>

<Tip>
  Give each application its own database and its own user. Sharing one user across several sites means one leaked password exposes all of them.
</Tip>

Database contents are included in your [hosting backups](/web-hosting/backup), but exporting before a major change remains the fastest way back.
