mysql-useful-commands
This is an old revision of the document!
Table of Contents
MySQL useful commands
Create Database User and Grant all rights to a DB
CREATE USER 'username'@'localhost' IDENTIFIED BY 'password'; 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');
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.1699116600.txt.gz · Last modified: 2023/11/04 17:50 by baumi