Updated MySQL tips (markdown)

ghost-from-the-past 2021-04-21 21:53:41 +02:00
parent 9c2f4bb91f
commit 9249dfc02c

@ -99,3 +99,25 @@ This tips were prepared for [[Install Tracks 2.5 on Ubuntu 20.10]]
<blockquote>
<p>&gt;mysql -u daniel -p tempe &lt; ~/tracks.sql</p>
</blockquote>
<h3>Assign privileges for a user on a database</h3>
<p>These are examples on how to grant some privileges</p>
<blockquote>
mysql&gt; GRANT USAGE ON *.* TO <em> <strong>thisuser/strong> </em>@localhost;<br/>
mysql&gt; GRANT ALL PRIVILEGES ON <em> <strong>thisdb</strong> </em>.* TO <em> <strong>thisuser/strong> </em>@localhost;<br/>
mysql&gt; GRANT GRANT OPTION ON <em> <strong>thisdb</strong> </em>.* TO <em> <strong>thisuser/strong> </em>@localhost; # Enables you to grant to or revoke from other users those privileges that you yourself possess.<br/>
mysql&gt;quit;
</blockquote>
<p>Note: for the dump of the database (using mysqldump) you need to add the <strong>global</strong> PROCESS privilege to the user running the command</p>
<blockquote>
mysql&gt;GRANT PROCESS ON *.* TO <em> <strong>thisuser/strong> </em>@localhost;
</blockquote>
<p>
<br/>
</p>
<p>Show privileges granted to the current MySQL user</p>
<blockquote>mysql&gt; SHOW GRANTS;</blockquote>
<p>Show privileges granted to the MySQL user (if you dont specify a host for the user name, MySQL assumes % as the host):</p>
<blockquote>mysql&gt; SHOW GRANTS FOR '<strong>user_name</strong>';</blockquote>
<p>Show privileges granted to a particular MySQL user account from a given host:</p>
<blockquote>mysql&gt; SHOW GRANTS FOR '<strong>user_name</strong>'@'<strong>host</strong>';</blockquote>