MySQL Commands

MySQL Commands

Login
mysql -u user -p

Show databases
SHOW DATABASES

Show users
SELECT user, host FROM mysql.user;

Describe user table
DESC mysql.user;

Create new user
CREATE USER ‘newuser'@'localhost' IDENTIFIED BY ‘password';
Then
GRANT ALL PRIVILEGES ON *.* TO ‘newuser'@'localhost';
then
FLUSH PRIVILEGES;

SHOW GRANTS FOR ‘username'@'localhost';

DROP USER ‘username'@'localhost';

Change user password
UPDATE mysql.user SET Password = PASSWORD(‘new-password-here') WHERE USER='username' AND Host='host';