MySQL Basic Commands

Connection :
mysql -u root -p

Show the list of the processes :
show full processlist\G

List users :
SELECT User, Host, Password FROM mysql.user;

Create a DB :
CREATE database `example`;

Create a User:
CREATE user 'user'@'localhost' IDENTIFIED BY "password";

Give privileges to a user :
grant all privileges on `example` . * to 'user'@'localhost';

Change the password :
UPDATE mysql.user SET Password=PASSWORD('password') WHERE User='user' AND Host='localhost';

SET PASSWORD FOR 'user'@'localhost' = PASSWORD('password');

Update the privileges :
flush privileges;

List databases:
show databases;

Is there replication and am I on the slave or on the master :
show master status\G
show slave status\G

Show privileges:
SHOW GRANTS FOR 'user'@'localhost';

Remove user:
DROP USER 'user'@'localhost';

2022-02-01 12:08:08


Add a Comment

Login or Register to post a Comment.