Creating a database for your WordPress website using the terminal is a straightforward process. Follow these steps to get started:
- Open your terminal.
- Log in to MySQL:
mysql -u root -p
You will be prompted to enter your MySQL root password.
- Create a new database:
CREATE DATABASE wordpress_db;
Replace wordpress_db
with your desired database name.
- 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.
- 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.
- Flush the privileges to ensure that they take effect:
FLUSH PRIVILEGES;
- Exit MySQL:
EXIT;
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.