Creating a database and a database user

An application needs two things: a database to store data in, and a user with permission to use it. Creating one without the other is the most common mistake.

The steps

In cPanel, open MySQL Databases.

  1. Create the database. Type a short name. Your account name and an underscore are added automatically, so typing "shop" produces something like account_shop. The full name is what your application needs.
  2. Create a user. Same prefixing applies. Use the password generator rather than inventing one – nothing has to remember it except a configuration file.
  3. Add the user to the database and grant ALL PRIVILEGES. This step is the one people miss, and without it the application connects and then fails on the first query.

What your application needs

  • Database name – the full prefixed name
  • Username – the full prefixed name
  • Password
  • Host – localhost, not your domain name

The name length limit

Database and user names are limited in length, and your account prefix counts toward it. If a long name is rejected, that is why – shorten the part you chose.

One database per application

Do not share one database between two applications unless the software specifically supports it. Separate databases mean you can back up, restore or delete one without touching the other.

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

Managing your MySQL databases

Everything to do with databases is in cPanel, in two places: MySQL Databases for creating and...

How databases and database users are named

Database and user names are always prefixed with your cPanel account name and an underscore. You...

Using phpMyAdmin without breaking anything

phpMyAdmin, in cPanel, gives you direct access to your data. That is useful and it is also the...

Importing a large database

phpMyAdmin has an upload size limit, and a large database import will fail part-way through...

Connecting to MySQL from your own computer

By default, databases only accept connections from the server itself. That is deliberate: it...