diff --git a/MySQL-tips.md b/MySQL-tips.md index 19c85c8..2f7f0fb 100644 --- a/MySQL-tips.md +++ b/MySQL-tips.md @@ -99,3 +99,25 @@ This tips were prepared for [[Install Tracks 2.5 on Ubuntu 20.10]]

>mysql -u daniel -p tempe < ~/tracks.sql

+

Assign privileges for a user on a database

+

These are examples on how to grant some privileges

+
+ +mysql> GRANT USAGE ON *.* TO thisuser/strong> @localhost;
+mysql> GRANT ALL PRIVILEGES ON thisdb .* TO thisuser/strong> @localhost;
+mysql> GRANT GRANT OPTION ON thisdb .* TO thisuser/strong> @localhost; # Enables you to grant to or revoke from other users those privileges that you yourself possess.
+mysql>quit; +
+

Note: for the dump of the database (using mysqldump) you need to add the global PROCESS privilege to the user running the command

+
+mysql>GRANT PROCESS ON *.* TO thisuser/strong> @localhost; +
+

+
+

+

Show privileges granted to the current MySQL user

+
mysql> SHOW GRANTS;
+

Show privileges granted to the MySQL user (if you don’t specify a host for the user name, MySQL assumes % as the host):

+
mysql> SHOW GRANTS FOR 'user_name';
+

Show privileges granted to a particular MySQL user account from a given host:

+
mysql> SHOW GRANTS FOR 'user_name'@'host';