mysql-useful-commands
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| mysql-useful-commands [2017/08/22 13:14] – [Update field and replace string] baumi | mysql-useful-commands [2024/09/06 18:20] (current) – baumi | ||
|---|---|---|---|
| Line 4: | Line 4: | ||
| ~~ | ~~ | ||
| ====== MySQL useful commands ====== | ====== MySQL useful commands ====== | ||
| - | ===== Create Database User and Grant all rights to a DB ===== | + | ===== User & Permissions ===== |
| + | ==== Create Database User ==== | ||
| <code sql> | <code sql> | ||
| CREATE USER ' | CREATE USER ' | ||
| + | </ | ||
| + | ==== Delete Database User ==== | ||
| + | <code sql> | ||
| + | DROP USER ' | ||
| + | </ | ||
| + | ==== Grant Permissions ==== | ||
| + | <code sql> | ||
| GRANT ALL privileges ON dbname.* TO ' | GRANT ALL privileges ON dbname.* TO ' | ||
| FLUSH privileges; | FLUSH privileges; | ||
| </ | </ | ||
| - | ===== Set new DB user password | + | ==== Set new DB user password ==== |
| <code sql> | <code sql> | ||
| SET PASSWORD FOR ' | SET PASSWORD FOR ' | ||
| </ | </ | ||
| + | === Delete Database User === | ||
| + | |||
| + | |||
| ===== Update field and replace string ===== | ===== Update field and replace string ===== | ||
| <code sql> | <code sql> | ||
| UPDATE TABLE SET FIELD = REPLACE(FIELD, | UPDATE TABLE SET FIELD = REPLACE(FIELD, | ||
| + | </ | ||
| + | |||
| + | ===== Restore MySQL system database in docker environment ===== | ||
| + | < | ||
| + | $ docker run --detach --rm --name mariadb-restore \ | ||
| + | --env MARIADB_USER=user \ | ||
| + | --env MARIADB_PASSWORD=password \ | ||
| + | --env MARIADB_ROOT_PASSWORD=root \ | ||
| + | --volume / | ||
| + | --volume $PWD/ | ||
| + | mariadb: | ||
| + | |||
| + | $ docker exec -it mariadb-restore bash | ||
| + | # mysql -u root -p mysql < / | ||
| + | # echo "flush privileges" | ||
| </ | </ | ||
| {{tag>kb mysql}} | {{tag>kb mysql}} | ||
mysql-useful-commands.1503400492.txt.gz · Last modified: by baumi
