You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For further information on Mariabackup, see the [Mariabackup Knowledge Base](https://mariadb.com/kb/en/mariabackup-overview/).
243
+
244
+
## How to reset root and user passwords
245
+
246
+
If you have an existing data directory and wish to reset the root and user passwords, and to create a database on which the user can fully modify, perform the following steps.
247
+
248
+
First create a `passwordreset.sql` file:
249
+
250
+
```text
251
+
CREATE USER IF NOT EXISTS root@localhost IDENTIFIED BY 'thisismyrootpassword';
252
+
SET PASSWORD FOR root@localhost = PASSWORD('thisismyrootpassword');
253
+
GRANT ALL ON *.* TO root@localhost WITH GRANT OPTION;
254
+
CREATE USER IF NOT EXISTS root@'%' IDENTIFIED BY 'thisismyrootpassword';
255
+
SET PASSWORD FOR root@'%' = PASSWORD('thisismyrootpassword');
256
+
GRANT ALL ON *.* TO root@'%' WITH GRANT OPTION;
257
+
CREATE USER IF NOT EXISTS myuser@'%' IDENTIFIED BY 'thisismyuserpassword';
258
+
SET PASSWORD FOR myuser@'%' = PASSWORD('thisismyuserpassword');
259
+
CREATE DATABASE IF NOT EXISTS databasename;
260
+
GRANT ALL ON databasename.* TO myuser@'%';
261
+
```
262
+
263
+
Adjust `myuser`, `databasename` and passwords as needed.
264
+
265
+
Then:
266
+
267
+
```console
268
+
$ docker run --rm -v /my/own/datadir:/var/lib/mysql -v /my/own/passwordreset.sql:/passwordreset.sql:z %%IMAGE%%:latest --init-file=/passwordreset.sql
269
+
```
270
+
271
+
On restarting the MariaDB container on this `/my/own/datadir`, the `root` and `myuser` passwords will be reset.
0 commit comments