Handy to know when installing WordPress, phpBB or any other fancy web applications requiring a database.
First log on to your MySQL server (assuming root user is being used)
mysql -u root -p
When logged on, create the database (called example).
CREATE DATABASE example;
Create a user with password and connection permission. If the web and MySQL server is on the same server, you just let it be localhost. If they are not on the same server, you could use a % instead of localhost. % means it can log on to MySQL from anywhere. That is a security issue. Specify the IP if the MySQL and Web server are on different servers.
CREATE USER ‘username’@’localhost’ IDENTIFIED BY ‘password’;
Now the user is created, and given a password. But still haven’t access to do anything. We will now give it access to use the example database from localhost. Just change the localhost to an ip or address if needed.
GRANT ALL PRIVILEGES ON example.* TO ‘username’@’localhost’;
Then we flush the permissions to activate them.
Your new database and user is now ready. To this in a WordPress, phpBB or any other application require MySQL database here is the details for this example:
Database Address: localhost
Database Name: example
Database Username: username
Database Password: password