7.2.1. Creating a Database and User

7.2.1. Creating a Database and User

We’ll assume that you’ve already installed MySQL and that you have it running and are familiar with the basics. Run the mysql client program from the command line so we can execute some administration commands. You should make sure that you are connected as a user with sufficient privileges (e.g. by specifying the -u root option to run as the MySQL root user).

First create a database called jboss within MySQL for use by JBoss.

mysql> CREATE DATABASE jboss; 
Query OK, 1 row affected (0.05 sec) 

Then check that it has been created.

mysql> SHOW DATABASES; 
+----------+ 
| Database | 
+----------+ 
| jboss    | 
| mysql    | 
| test     | 
+----------+ 
3 rows in set (0.00 sec) 

Next, create a user called jboss with password password to access the database.

mysql> GRANT ALL PRIVILEGES ON jboss.* TO jboss@localhost IDENTIFIED BY 'password'; 
Query OK, 0 rows affected (0.06 sec) 

Again, you can check that everything has gone smoothly.

mysql> select User,Host,Password from mysql.User; 
+-------+-----------+------------------+ 
| User  | Host      | Password         | 
+-------+-----------+------------------+ 
| root  | localhost |                  |
| root  | %         |                  | 
|       | localhost |                  | 
|       | %         |                  | 
| jboss | localhost | 5d2e19393cc5ef67 | 
+-------+-----------+------------------+ 
5 rows in set (0.02 sec)