开发者

How to create users in MySQL4

开发者 https://www.devze.com 2023-04-13 03:17 出处:网络
I tried using the \"create user\" command in a MySQL4 database (something similar to what is available in the MySQL5 docs), but it failed. Can so开发者_StackOverflow中文版meone provide me the right sy

I tried using the "create user" command in a MySQL4 database (something similar to what is available in the MySQL5 docs), but it failed. Can so开发者_StackOverflow中文版meone provide me the right syntax?


Users are created the first time you GRANT them a privilege.

From http://dev.mysql.com/doc/refman/4.1/en/grant.html :

The GRANT statement creates MySQL user accounts and grants rights to accounts.

So, let's say you have a database "mydb", with a table "mytable". If you want to create a user "jason", with the password "pwd123!" who has SELECT privileges on this table, you can do this:

grant select on mydb.mytable to 'jason'@'hostname' identified by 'pwd123!';

The usual caveats about hostname apply.

If you want to give jason full permissions on mydb:

grant all on mydb.* to 'jason'@'hostname' identified by 'pwd123!';

Important note: every time you use identified by, you're changing the password for that user/hostname, so you you will typically only use this syntax when creating a user!

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号