create/delete users
--------------------
CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password';
DROP USER ‘demo’@‘localhost’;
Change passwords
-------------------
mysqladmin -u USER -p password NEWPASSWORD
mysqladmin -u marcelo -p oLdpa$$word 'NEwP@$$'
mysql> use mysql;
SET PASSWORD FOR 'user-name-here'@'hostname-name-here' = PASSWORD('new-password-here');
flush privileges;
GRANTING/REVOKE PRIVILEGES
--------------------------
GRANT ALL PRIVILEGES ON *.* TO 'newuser'@'localhost';
OR
GRANT ALL PRIVILEGES ON demoDB.* TO 'newuser'@'localhost';
GRANT SELECT,UPDATE,DELETE ON testDB.* TO 'demo-user'@'localhost';
REVOKE UPDATE ON testDB.* FROM 'demo-user'@'localhost';
GRANT ALL ON testDB.* TO 'demo-user'@'localhost';
FLUSH PRIVILEGES;
show grants for 'demo-user'@'localhost';
Privileges:-
= = = = = =
ALL PRIVILEGES,CREATE,DROP,DELETE,INSERT,SELECT,UPDATE,GRANT OPTION
- ALL PRIVILEGES- as we saw previously, this would allow a MySQL
user all access to a designated database (or if no database is selected,
across the system)
- CREATE- allows them to create new tables or databases
- DROP- allows them to them to delete tables or databases
- DELETE- allows them to delete rows from tables
- INSERT- allows them to insert rows into tables
- SELECT- allows them to use the Select command to read through databases
- UPDATE- allow them to update table rows
- GRANT OPTION- allows them to grant or remove other users' privileges
To provide a specific user with a permission, you can use this framework:
GRANT [type of permission] ON [database name].[table name] TO ‘[username]’@'localhost’;
The root login can be changed with the following command:
----------------------------------------------------------
rename user 'root'@'localhost' to 'newAdminUser'@'localhost';
No comments:
Post a Comment