How to Create a Database for a WordPress Website in the Terminal

Creating a database for your WordPress website using the terminal is a straightforward process. Follow these steps to get started:

  1. Open your terminal.
  2. Log in to MySQL:
mysql -u root -p

You will be prompted to enter your MySQL root password.

  1. Create a new database:
CREATE DATABASE wordpress_db;

Replace wordpress_db with your desired database name.

  1. Create a new MySQL user:
CREATE USER 'wp_user'@'localhost' IDENTIFIED BY 'password';

Replace wp_user with your desired username and password with a strong password.

  1. Grant the new user privileges on the database:
GRANT ALL PRIVILEGES ON wordpress_db.* TO 'wp_user'@'localhost';

This command gives the user all the necessary permissions to manage the database.

  1. Flush the privileges to ensure that they take effect:
  1. Exit MySQL:

Your new database and user are now ready for use with WordPress. Use the database name, username, and password in your WordPress configuration file to connect your website to the database.

Leave a Reply