Skip to main content

Creating a MySQL Database and User

databases, mysql, setup 0 Was this answer helpful?

Most web applications (WordPress, Joomla, custom PHP applications) require a MySQL database. In cPanel, you need to create three things: a database, a user, and then assign the user to the database with the appropriate privileges.

Please note: Screens and options may vary slightly depending on your cPanel version and hosting plan.

Step 1: Create the Database

  1. Log in to your cPanel account.
  2. In the Databases section, click MySQL Databases.
  3. Under Create New Database, enter a name for the database. cPanel will prefix it with your account username (e.g. username_mydatabase).
  4. Click Create Database.

Step 2: Create a Database User

  1. On the same MySQL Databases page, scroll down to MySQL Users.
  2. Under Add New User, enter a Username and a strong Password.
  3. Click Create User.

Step 3: Assign the User to the Database

  1. Scroll down to Add User To Database.
  2. Select the User and the Database from the dropdowns.
  3. Click Add.
  4. On the privileges page, select the permissions you want to grant. For most web applications, select ALL PRIVILEGES.
  5. Click Make Changes.

Finding Your Database Connection Details

Your application will need these details to connect to the database:

| Setting | Value | |---------|-------| | Database Name | username_mydatabase (as shown in cPanel) | | Database User | username_myuser (as shown in cPanel) | | Database Password | The password you set in Step 2 | | Database Host | localhost (for applications on the same server) |

Tips

  • Database and user names in cPanel are always prefixed with your cPanel username and an underscore. Keep the names you enter short.
  • The localhost hostname works for applications running on the same server. For remote connections, see the Remote MySQL article.
  • If you're installing an application through Softaculous, the database, user, and privileges are created automatically.
  • You can create multiple databases and users as needed. Each can have different privilege levels.

What Next?

Related Articles

knowledgebasedidyoufindanswer