User Tools

Site Tools


mysql-useful-commands

MySQL useful commands

User & Permissions

Create Database User

CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';

Delete Database User

DROP USER 'username'@'localhost';

Grant Permissions

GRANT ALL privileges ON dbname.* TO 'username'@'localhost';
FLUSH privileges;

Set new DB user password

SET PASSWORD FOR 'user-name-here'@'hostname-name-here' = PASSWORD('new-password-here');

Delete Database User

Update field and replace string

UPDATE TABLE SET FIELD = REPLACE(FIELD, 'old string', 'new string')

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 /srv/base-mariadb/BACKUP:/BACKUP:ro \
	--volume $PWD/data:/var/lib/mysql \
	mariadb:10.5

$ docker exec -it mariadb-restore bash
# mysql -u root -p mysql < /BACKUP/mysql.dump
# echo "flush privileges" | mysql -u root -p
mysql-useful-commands.txt · Last modified: 2024/09/06 18:20 by baumi

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki