SQL administration

(All this commands are for MySQL)

Connection

Connect to DB from CLI

mysql -u {$user} -p    

User

  • SELECT CURRENT_USER(); See current logged user
Change password when we know the old one
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('myNewPassword');
Create new User
CREATE USER 'user'@'localhost' IDENTIFIED BY 'password';
Grant Privileges to user
GRANT ALL PRIVILEGES ON *.* TO 'user'@'localhost'
	WITH GRANT OPTION;