Casbay Knowledge Base

Search our articles or browse by category below

Setting Up MySQL Database On Linux VPS Server For WordPress in 4 Steps

Last modified: September 30, 2022
You are here:
  • KB Home
  • new
  • Setting Up MySQL Database On Linux VPS Server For WordPress in 4 Steps
Estimated reading time: 1 min

If you are hosting a website on a Linux VPS Server, there may be a high chance that you had experienced in using the content management system, WordPress for your website. To set up a MySQL database for WordPress, you are required to install the LAMP stack in VPS. In this article, we will be guiding you on how to set up your MySQL database on WordPress.

Step 1: Log In With Root Account

Firstly, we will need to log into your MySQL root account by entering the following command in your terminal.

sudo mysql -u root -p

Enter the root password that you had set for during your MySQL installation when prompted.

Step 2: Create Database

After that, you will want to create a new database for your WordPress, and to do that, open your MySQL terminal and run the following command.

CREATE DATABASE <database_name> DEFAULT CHARACTER SET utf COLLATE utf8_unicode_ci;

Replace “<database_name>” with a database name of your preference in the command above.

Step 3: Create User Account

After that, we will need a new MySQL user account to operate the newly made database. To create the new user account, enter the following code into the MySQL terminal and run it

GRANT ALL ON <database_name>.* TO '<username>'@'localhost' IDENTIFIED BY '<password>';

Replace “<username>” with a username of your preference. To set your password, replace the “<password>” with a complex and strong password of your own.

Step 4: Save changes

Finally, to save changes, flush the privileges in the MySQL terminal as the following code to implement all the changes made.

FLUSH PRIVILEGES;

After you have saved changes, exit MySQL with the following command and you have finished setting up your database on WordPress with MySQL.

EXIT;
Was this article helpful?
Dislike 0
Next: Redirecting In Linux VPS Server With Nginx