This is post # four ( 4 ) of this series and it’s going to show students and new users how to create WordPress a database and the database user. Our new series about WordPress is all about setting up and managing WordPress on Ubuntu.
This post has been tested on Ubuntu 17.04 | 17.10.
In part one of the series, we showed you how to prepare the Ubuntu server for WordPress. Part two and three showed you how to install LAMP or LEMP to run WordPress. This post shows you how to create WordPress databases and users after installing LAMP or LEMP for WordPress.
To read our previous posts, please search this website.
Post # 2 and 3 showed you how to install LAMP and LEMP with MySQL as the database server. For those who prefer to use an alternative database servers can install MariaDB database server instead.
MariaDB is a drop-in replacement for MySQL. It functions and operates like MySQL and applications using either wouldn’t know the difference.
To install and use MariaDB instead of MySQL, run the commands below.
sudo apt-get update sudo apt-get install mariadb-server mariadb-client
After installing the database server above, the commands below can be used to stop, start and enable MariaDB to always start up when the server boots up.
sudo systemctl stop mariadb.service sudo systemctl start mariadb.service sudo systemctl enable mariadb.service
Next, run the commands below to secure the database server. The commands below works on both MySQL and MariaDB.
You should be prompted with series of questions.. use the guide below to answer for MariaDB:
Enter current password for root (enter for none): PRESS ENTER Set root password? [Y/n] Y CREATE YOUR PASSWORD Remove anonymous users? [Y/n] Y Disallow root login remotely? [Y/n] Y Remove test database and access to it? [Y/n] Y Reload privilege tables now? [Y/n] Y
For MySQL, you’ll be prompted to enter the current root password you created during the installation. Enter it and use the same guide above.. although might be a bit different.
Create WordPress Database and User
Now that the database server is installed run the commands below to create WordPress a database and a database user. WordPress uses databases to store its content. The database user account is used to manage the database content.
After installing MySQL server, run the commands below to logon to the database server
sudo mysql -u root -p
You’ll be prompted to enter a root password. Type the one you created above for the root user.
Next, run the SQL commands below to create a database called wordpressdb.
CREATE DATABASE wordpressdb;
Run the commands below to create a new user named wpuser with new password, and grant the user access to the wordpressdb databases.
GRANT ALL ON wordpressdb.* TO 'wpuser'@'localhost' IDENTIFIED BY 'type_new_password_here';
After that, run the commands below to save your changes and exit.
FLUSH PRIVILEGES; exit
When you exit, the database should be ready to use.
This post shows you how to create WordPress database and the database user. WordPress uses databases to store it content and the user is used to manage the content stored in the database.
The commands to create the database and user should work on both MySQL and MariaDB.
In our next post, we’ll show you how to download WordPress content and configure WordPress.
Post three can be found below: