Skip to content

Latest commit

 

History

History
46 lines (35 loc) · 833 Bytes

MySQL.md

File metadata and controls

46 lines (35 loc) · 833 Bytes

MySQL Guide

Create Database

mysql -u root -p
mysql> CREATE DATABASE dbname;

Create New User

mysql> CREATE USER 'dbuser'@'localhost' IDENTIFIED BY 'password';
mysql> GRANT ALL PRIVILEGES ON dbname.* TO 'dbuser'@'localhost';
mysql> GRANT ALL PRIVILEGES ON dbname.* TO 'dbuser'@'localhost' IDENTIFIED BY 'password';
mysql> FLUSH PRIVILEGES;

Delete User

mysql> DROP USER ‘username’@‘localhost’;

Backup

Backup / Restore Database

mysqldump -u dbuser -p dbname > dbname-$(date +%F).sql
mysql -u dbuser -p dbname < filename.sql

Full-Backup / Restore of the DBMS

mysqldump --all-databases --single-transaction --quick --lock-tables=false > full-backup-$(date +%F).sql -u root -p
mysql -u root -p < full-backup.sql