memo xwiki inial
To create a database, a user, and set a password in your MariaDB container for use with XWiki, you’ll need to access the MariaDB command line interface and run a few SQL commands. Here’s how you can do it step-by-step:
### Step 1: Access the MariaDB Container
First, you need to access the shell of your MariaDB container. Assuming the name of your MariaDB container is `mariadb`, you can use the following Docker command:
```bash
docker exec -it mariadb bash
```
### Step 2: Log into MariaDB
Once you are inside the container, log in to the MariaDB command line interface:
```bash
mysql -u root -p
```
You will be prompted to enter the root password that you specified when setting up the MariaDB container.
### Step 3: Create the Database
Run the following SQL command to create a new database for XWiki. Replace `xwikidb` with the name you want for your database:
```sql
CREATE DATABASE xwikidb CHARACTER SET utf8 COLLATE utf8_bin;
```
### Step 4: Create a User
Now, create a user and grant them access to the newly created database. Replace `xwikiuser` and `xwikipassword` with the username and password you wish to use:
```sql
CREATE USER 'xwikiuser'@'%' IDENTIFIED BY 'xwikipassword';
GRANT ALL PRIVILEGES ON xwikidb.* TO 'xwikiuser'@'%';
```
Here, `'%'` means that the user can connect from any host within the Docker network. This is suitable for Docker environments where services might communicate from different containers.
### Step 5: Apply the Changes
To ensure that all changes take effect immediately, flush the privileges:
```sql
FLUSH PRIVILEGES;
```
### Step 6: Exit
Now that your database and user are set up, you can exit the MariaDB command line:
```sql
EXIT;
```
Then exit the container's shell:
```bash
exit
```
### Step 7: Use These Credentials in XWiki
Now, use the database name (`xwikidb`), username (`xwikiuser`), and password (`xwikipassword`) in your XWiki Docker run command as shown in previous steps. This will allow XWiki to connect to the MariaDB database.
Here’s a quick recap of the Docker command to run XWiki with these database settings:
```bash
docker run -d --name testwiki \
-p 5297:8080 \
-e DB_USER=xwikiuser \
-e DB_PASSWORD=xwikipassword \
-e DB_DATABASE=xwikidb \
-e DB_HOST=mariadb \
--network my-net \
xwiki:latest
```
This setup ensures that XWiki can connect to the MariaDB database using the user and password you just created, all within a secure Docker network environment.
评论
发表评论