Posts From Category: sql

MySQL user privileges

How to grant privileges for a database to a user, when both already exist.

In this case the database name will be project_node1, the user project_user and the password project_pass. All the following commands have to be executed as root or with a user with enough privileges.

-- list system users
SELECT user, host FROM mysql.user;

-- see current privileges
SHOW GRANTS FOR 'project_user'@'%';

-- delete all previous privileges (if needed)
-- REVOKE ALL PRIVILEGES ON `project_node1`.* FROM 'project_user'@'%';

-- grant new privileges and flush
GRANT ALL PRIVILEGES ON `project_node1`.* TO 'project_user'@'%';


Read More

SQL administration

(All this commands are for MySQL)


Connect to DB from CLI

mysql -u {$user} -p    


  • SELECT CURRENT_USER(); See current logged user
Change password when we know the old one
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('myNewPassword');

Read More