DEV Community

Vikram Sharma
Vikram Sharma

Posted on • Edited on

Setup MySQL Database for WordPress

Here are the steps for setting up a database for WordPress on a Ubuntu server(Assuming MySQL in already installed).

  1. Log into mysql using root
    ''' sudo mysql -u root'''
    Note: On new Ubuntu version password is not required.

  2. Create a database.

CREATE DATABASE IF NOT EXISTS wordpress DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;

Or use UTF8mb4 if you want emojis.

CREATE DATABASE IF NOT EXISTS wordpress DEFAULT CHARACTER SET UTF8mb4 collate utf8mb4_bin;

  1. Create a User

CREATE USER IF NOT EXISTS 'wordpressuser'@'localhost' IDENTIFIED BY 'password';

CREATE USER IF NOT EXISTS 'wordpressuser'@'%' IDENTIFIED BY 'password';

  1. Grant privileges to the user

GRANT ALL PRIVILEGES ON wordpress.* TO 'wordpressuser'@'localhost';

GRANT ALL PRIVILEGES ON wordpress.* TO 'wordpressuser'@'%';

5.

FLUSH PRIVILEGES;

6.

\q

Nuff said.

Top comments (0)