===== Install mycli =====
[[https://github.com/dbcli/mycli|mycli]]
yaourt -S mycli
===== Login to mysql shell =====
mycli -u root -p
===== Create database =====
CREATE DATABASE newdatabase;
USE newdatabase
===== Create user and grant the database access =====
CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'newpassword';
GRANT ALL PRIVILEGES ON newdatabase.* TO 'newuser'@'localhost';
===== Change credential =====
mysqladmin -u root password 'new-password'
mysqladmin -u root -h localhost password 'new-password'
SET PASSWORD FOR 'user'@'localhost' = PASSWORD('password');
-- or
update mysql.user set password=PASSWORD(‘新password’) where User=’root’;
-- and then
flush privileges;
===== Show users =====
select * from mysql.user;
===== Show grants =====
SHOW DATABASES;
SELECT host, user, password FROM mysql.user;
SHOW GRANTS FOR username@localhost;
===== Remote grants =====
revoke all privileges on newdatabase.* from 'newuser'@'localhost';
flush privileges;
===== List databases =====
SHOW DATABASES
===== List tables =====
SHOW TABLES