# How to create new database and user with the chart

**URL:** <https://forums.percona.com/t/how-to-create-new-database-and-user-with-the-chart/28065>\
**Category:** Percona Operator for MySQL\
**Created:** [January 26, 2024, 10:46am UTC](https://forums.percona.com/t/how-to-create-new-database-and-user-with-the-chart/28065 "2024-01-26T10:46:27Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![sohamc](https://avatars.discourse-cdn.com/v4/letter/s/9f8e36/32.png) [@sohamc](https://forums.percona.com/u/sohamc)\
**Post date:** [January 26, 2024, 10:46am UTC](https://forums.percona.com/t/how-to-create-new-database-and-user-with-the-chart/28065/1 "2024-01-26T10:46:27Z")

</div>

## Description:

We are exploring [GitHub - percona/percona-xtradb-cluster-operator: Percona Operator for MySQL based on Percona XtraDB Cluster](https://github.com/percona/percona-xtradb-cluster-operator) to set up mysql cluster. Now I am looking to create an user(s) and empty databases along with the installation. Is there something documented in some blog post/article somewhere that I can follow?

## Steps to Reproduce:

Install the cluster, no option to create an empty database or user is there.

## Version:

v1.13.0

## Logs:

## Expected Result:

NA

## Actual Result:

NA

## Additional Information:

NA

---

<div class="post-metadata">

**Author:** ![matthewb](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/matthewb/32/34_2.png) [@matthewb](https://forums.percona.com/u/matthewb)\
**Post date:** [January 26, 2024, 4:33pm UTC](https://forums.percona.com/t/how-to-create-new-database-and-user-with-the-chart/28065/2 "2024-01-26T16:33:45Z")

</div>

Hello @sohamc,  
Check out our [official documentation](https://docs.percona.com/percona-operator-for-mysql/pxc/) on the PXC Operator.

---

<div class="post-metadata">

**Author:** ![sohamc](https://avatars.discourse-cdn.com/v4/letter/s/9f8e36/32.png) [@sohamc](https://forums.percona.com/u/sohamc)\
**Post date:** [January 26, 2024, 6:10pm UTC](https://forums.percona.com/t/how-to-create-new-database-and-user-with-the-chart/28065/3 "2024-01-26T18:10:46Z")

</div>

Hi,

Thank you for replying.

I did look through the documentation but didn’t find any option to create any user or database along with the installation. Do we need to do this outside of the cluster installation?

Thanks,

---

<div class="post-metadata">

**Author:** ![matthewb](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/matthewb/32/34_2.png) [@matthewb](https://forums.percona.com/u/matthewb)\
**Post date:** [January 26, 2024, 7:40pm UTC](https://forums.percona.com/t/how-to-create-new-database-and-user-with-the-chart/28065/4 "2024-01-26T19:40:09Z")

</div>

Hello @sohamc,  
Yes, typically you would log into MySQL and `CREATE DATABASE` and `CREATE USER`.

---

<div class="post-metadata">

**Author:** ![Sergey\_Pronin](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/sergey_pronin/32/14887_2.png) [@Sergey\_Pronin](https://forums.percona.com/u/Sergey_Pronin)\
**Post date:** [January 29, 2024, 8:11am UTC](https://forums.percona.com/t/how-to-create-new-database-and-user-with-the-chart/28065/5 "2024-01-29T08:11:08Z")

</div>

@sohamc - right now this is not supported in our MySQL Operator. But it is our top pick in the roadmap: [[K8SPXC-377] Create MySQL users through operator · Issue #9 · percona/roadmap · GitHub](https://github.com/percona/roadmap/issues/9)

---

<div class="post-metadata">

**Author:** ![sohamc](https://avatars.discourse-cdn.com/v4/letter/s/9f8e36/32.png) [@sohamc](https://forums.percona.com/u/sohamc)\
**Post date:** [January 30, 2024, 7:16am UTC](https://forums.percona.com/t/how-to-create-new-database-and-user-with-the-chart/28065/6 "2024-01-30T07:16:35Z")

</div>

Thank you, looking forward to it.

---

<div class="post-metadata">

**Author:** ![sohamc](https://avatars.discourse-cdn.com/v4/letter/s/9f8e36/32.png) [@sohamc](https://forums.percona.com/u/sohamc)\
**Post date:** [January 30, 2024, 3:24pm UTC](https://forums.percona.com/t/how-to-create-new-database-and-user-with-the-chart/28065/7 "2024-01-30T15:24:47Z")

</div>

Hi @Sergey_Pronin, in [Is there a built-in way to get "CREATE DATABASE app;" and app user created? - #3 by Sergey\_Pronin](https://forums.percona.com/t/is-there-a-built-in-way-to-get-create-database-app-and-app-user-created/9133/3) you said that this can be easily solved by automation tools. Can you please share couple (any) examples that I can go through and try to implement?

Also is there any ETA on the expected release of [[K8SPXC-377] Create MySQL users through operator · Issue #9 · percona/roadmap · GitHub](https://github.com/percona/roadmap/issues/9)? Not looking for any set in stone date, just an expectation in terms of Q1/Q2 or something like that.

---

<div class="post-metadata">

**Author:** ![Sergey\_Pronin](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/sergey_pronin/32/14887_2.png) [@Sergey\_Pronin](https://forums.percona.com/u/Sergey_Pronin)\
**Post date:** [February 5, 2024, 8:28am UTC](https://forums.percona.com/t/how-to-create-new-database-and-user-with-the-chart/28065/8 "2024-02-05T08:28:42Z")

</div>

@sohamc well, apart from just connecting to the database and executing the “create …” statements, I don’t have anything.  
Also there are some teams using liquibase or similar products to create schemas.

As for ETA - Q2/Q3 more likely, unless someone from the community does it earlier.

---

<div class="post-metadata">

**Author:** ![Adrien\_Barret](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/adrien_barret/32/18205_2.png) [@Adrien\_Barret](https://forums.percona.com/u/Adrien_Barret)\
**Post date:** [September 25, 2024, 2:11pm UTC](https://forums.percona.com/t/how-to-create-new-database-and-user-with-the-chart/28065/9 "2024-09-25T14:11:30Z")

</div>

> [@Sergey\_Pronin](#):
>
> As for ETA - Q2/Q3 more likely, unless someone from the community does it earlier.

do you have any update on this ? any release ?

---

<div class="post-metadata">

**Author:** ![Slava\_Sarzhan](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/slava_sarzhan/32/3196_2.png) [@Slava\_Sarzhan](https://forums.percona.com/u/Slava_Sarzhan)\
**Post date:** [September 26, 2024, 4:04pm UTC](https://forums.percona.com/t/how-to-create-new-database-and-user-with-the-chart/28065/10 "2024-09-26T16:04:38Z")

</div>

Hi @Adrien_Barret , it is under development right now. We will include it as a tech preview in the next PXCO release. I hope we can release PXCO 1.16.0 next month. P.S. As soon as we merge PR you can test it (please use not a production cluster) you can test it to provide feedback.

---

<div class="post-metadata">

**Author:** ![Adrien\_Barret](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/adrien_barret/32/18205_2.png) [@Adrien\_Barret](https://forums.percona.com/u/Adrien_Barret)\
**Post date:** [September 26, 2024, 4:46pm UTC](https://forums.percona.com/t/how-to-create-new-database-and-user-with-the-chart/28065/11 "2024-09-26T16:46:06Z")

</div>

Awesome, is it possible for you to update this issue when it will be release?

ty,

Adrien

---

<div class="post-metadata">

**Author:** ![Sergey\_Pronin](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/sergey_pronin/32/14887_2.png) [@Sergey\_Pronin](https://forums.percona.com/u/Sergey_Pronin)\
**Post date:** [September 27, 2024, 9:46am UTC](https://forums.percona.com/t/how-to-create-new-database-and-user-with-the-chart/28065/12 "2024-09-27T09:46:00Z")

</div>

@Adrien_Barret we will update it 🙂

BTW, maybe you can help us to validate the solution. Here is how the spec is going to look like:

```auto
spec: 
  users: 
  - name: my-user
    db:
    - test1
    - test2
    hosts:
    - %
    - localhost
    - 111.111.111.111
	passwordSecretRef: 
	  name: my-user-password 
    key: my-user-password-key
  withGrantOption: yes
	grants: 
	- REPLICATION SLAVE
	- ALL

```

As a result, the Operator will execute the following statements in the database:

```auto
CREATE DATABASE IF NOT EXISTS test1;
CREATE DATABASE IF NOT EXISTS test2;
CREATE USER IF NOT EXISTS 'my-user'@'localhost' IDENTIFIED BY 'password1';
CREATE USER IF NOT EXISTS 'my-user'@'111.111.111.111' IDENTIFIED BY 'password1';
CREATE USER IF NOT EXISTS 'my-user'@'%' IDENTIFIED BY 'password1';
GRANT ALL, REPLICATION SLAVE ON test1.*, test2.* TO 'my-user'@'localhost', 'my-user'@'%', 'my-user'@'111.111.111.111' WITH GRANT OPTION ;

```

What do you think?

---

<div class="post-metadata">

**Author:** ![Adrien\_Barret](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/adrien_barret/32/18205_2.png) [@Adrien\_Barret](https://forums.percona.com/u/Adrien_Barret)\
**Post date:** [September 27, 2024, 1:16pm UTC](https://forums.percona.com/t/how-to-create-new-database-and-user-with-the-chart/28065/13 "2024-09-27T13:16:30Z")

</div>

great for me ! 🙂  
May be hosts can be all \* by default expet if hosts key is refered but it’s a minor thing.  
Password can optional and if not secretRef is referet it would be auto-generated to kept it only into kubernetes too

Will wait for the release !

---

<div class="post-metadata">

**Author:** ![yotles](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/yotles/32/1293_2.png) [@yotles](https://forums.percona.com/u/yotles)\
**Post date:** [June 10, 2025, 3:00pm UTC](https://forums.percona.com/t/how-to-create-new-database-and-user-with-the-chart/28065/14 "2025-06-10T15:00:19Z")

</div>

@Slava_Sarzhan Hi. Could you please confirm that user managing is under tech preview starting from PXCO 1.16.0 and really work? Thanks.

---

<div class="post-metadata">

**Author:** ![Slava\_Sarzhan](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/slava_sarzhan/32/3196_2.png) [@Slava\_Sarzhan](https://forums.percona.com/u/Slava_Sarzhan)\
**Post date:** [August 29, 2025, 7:51pm UTC](https://forums.percona.com/t/how-to-create-new-database-and-user-with-the-chart/28065/15 "2025-08-29T19:51:03Z")

</div>

Hi, it works. Please use it and provide your feedback. We will remove tech preview from next release.
