MySQL basic command

Login as root without password

sudo -i
mysql

create user

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

create database

CREATE DATABASE database_name

grant privileges to user

GRANT ALL PRIVILEGES ON database_name.* TO 'username'@'localhost';

change password

SET PASSWORD FOR 'username'@'localhost' = 'password';

import database

mysql -u username -p new_database < data-dump.sql

export database

mysqldump -u username -p database_name > data-dump.sql

check the outcome

head -n 5 data-dump.sql

update

UPDATE wp_options SET option_value = 'new_domain' where option_value like 'old_domain';

drop table

DROP TABLE IF EXISTS `tablename`;