MySQL – Create database and user with permissions

mysql-database-logo-webHandy 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.
FLUSH PRIVILEGES;

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

Happy databasing!

About Author

Related Posts

mysql double vs float

MySQL: Double vs Float

When it comes to mysql double vs float to storing numbers with decimal places in a database, two of the most commonly used data types in MySQL…

mysql table does not exist

mysql table does not exist

mysql table does not exist Mysql table does not exist, but it is there. I can see it when I run show databases. Did you manually move…

Mono Develop – Use .net MySql connector

A short example on how to use the .net MySql connector with Mono Develop.First you need to make it available to your project.Go to Project -> Edit…

Mono Develop (Linux) – Install .net MySql Connector

Here is how to install a .net MySql connector for Mono Develop for Linux (Tested for Debian Variants). First we is going to download the connector, and…

Debian & Ubuntu – Recovering MySQL root password

Haven’t needed to reset my MySQL root passwords yet, but I suspect someday…. On a Debian based system this is easy and also demonstrate the importance of…

Debian – Basic LAMP

Setup a basic LAMP, enables you to host cool web applications. LAMP is Linux, Apache, MySQL & PHP (guess Perl or Python should qualify as well). I…

Leave a Reply