Database users and privileges

This article will be reviewing the process of creating a new database user and assign all database privileges to this user (or to an existing user) so that the database can finally be connected to your WordPress installation.

If you have read the previous article about creating databases, you should already be able to access the MySQL databases manager interface.

Once you are on this page, you can proceed on creating the new database user.

Creating new database user

Note that this step is not always mandatory, as you might want to assign database privileges to an already existing database user. If you don’t want to create a new user, you can skip this step.

On the MySQL databases page, scroll down until you find the database users tab and create the user with the desired username and password. Note that in most cases usernames will be prefixed with your hosting account name. For passwords, most hosting providers offer a password generator button to make sure that your password will be secure. Make sure to copy and save the username and password as you will need these credentials when connecting the database to WordPress.

Assign User to Database

Once you have a database user, you can assign it to a database so it can read, write, modify database information.  

Enable all privileges to the Database User

Once you click on the “Add” button, the user will be added to the database and you will be redirected to the user privileges page. For the user to be able to interact with your database, we recommend enabling ALL privileges:

Connecting the database to WordPress

After completing the step above, your database is ready to be connected to WordPress.

You can do that by adding the database name, database user credentials in the wp-config.php file.

You can find this file in the root directory of your WordPress installation. Open this file and look for the following lines:

// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'database_name');

/** MySQL database username */
define('DB_USER', 'database_username');

/** MySQL database password */
define('DB_PASSWORD', 'database_user_password');

/** MySQL hostname */
define('DB_HOST', 'localhost');

/** Database Charset to use in creating database tables. */
define('DB_CHARSET', 'utf8mb4');

/** The Database Collate type. Don't change this if in doubt. */
define('DB_COLLATE', '');

Replace the relevant details with the ones you just created:

Replace database_name with the MySQL database, the database_username with the name of the user you created and database_user_password with the user password that you created in the previous step.

All Done!

Once that is done, you should be able to access your WordPress installation and include the basic website information (website title, tagline, administrator username and password)

After including these details and clicking the “Install WordPress” button, your website is ready to use.