Difference between revisions of "MySQL"

From Briki
Jump to: navigation, search
 
Line 13: Line 13:
 
<pre>
 
<pre>
 
GRANT ALL ON database.* TO myuser@localhost;
 
GRANT ALL ON database.* TO myuser@localhost;
 +
</pre>
 +
To allow login for a user from a remote host (2 lines are needed because, without the first, the user privileges default to those of the anonymous local user):
 +
<pre>
 +
GRANT ALL ON database.* TO myuser@localhost IDENTIFIED BY 'password';
 +
GRANT ALL ON database.* TO myuser@'%' IDENTIFIED BY 'password';
 
</pre>
 
</pre>
 
Obviously, different privileges can be assigned to databases and tables. To revoke privileges, the syntax is:
 
Obviously, different privileges can be assigned to databases and tables. To revoke privileges, the syntax is:

Revision as of 17:25, 22 June 2006

Assigning passwords to users

Login to mysql as the relevant user and run:

SET PASSWORD = PASSWORD('biscuit');

Creating new users

Login to mysql as root, and run:

GRANT ALL ON database.* TO myuser@localhost IDENTIFIED BY 'password';

Or, to create a user with no password:

GRANT ALL ON database.* TO myuser@localhost;

To allow login for a user from a remote host (2 lines are needed because, without the first, the user privileges default to those of the anonymous local user):

GRANT ALL ON database.* TO myuser@localhost IDENTIFIED BY 'password';
GRANT ALL ON database.* TO myuser@'%' IDENTIFIED BY 'password';

Obviously, different privileges can be assigned to databases and tables. To revoke privileges, the syntax is:

REVOKE ALL ON database.* FROM myuser@localhost;