此内容没有您所选择的语言版本。

8.2. MySQL as the Default Datasource


The MySQL® database has become the most popular open source database. We will configure a datasource to this database for demonstration purposes.
In this example we are using MySQL 5.1.31 and Connector/J 5.1.8, the official JDBC driver. Both are available at www.mysql.com.

8.2.1. Creating a Database and User

We’ll assume that you have already installed MySQL, 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 (for example, 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)
Copy to Clipboard Toggle word wrap
Then check that it has been created:
mysql> SHOW DATABASES;
+----------+
| Database |
+----------+
| jboss    |
+----------+
1 rows in set (0.00 sec)
Copy to Clipboard Toggle word wrap
Next, create a user called jboss with 'password' as the 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)
Copy to Clipboard Toggle word wrap
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)
Copy to Clipboard Toggle word wrap
返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2025 Red Hat