Wellcome to MySQL command line tool

Start command line

mysql -u root -p mysql

after press Enter button, type mysql root password and press Enter again.

Show users list

select user, host from mysql.user;

Change user password

set password for 'user_name' = 'new pass'

Create new user

Full access to database

GRANT ALL PRIVILEGES ON yourDB.* TO 'user'@'%' IDENTIFIED BY 'password';

Partial access to database

GRANT SELECT, INSERT ON yourDB.yourTable to 'user'@'%' IDENTIFIED BY 'password'; 
GRANT UPDATE ON yourDB.yourTable2 to 'user'@'%';

Show all user privileges


Delete user

delete from mysql.user where user = 'user';

Remove priveleges for user

REVOKE ALL PRIVILEGES ON task.* FROM 'user31'@'%';

Accept changes


Leave a Comment