1

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 someone provide me the right syntax?

5
  • 1
    Have you looked at the old documentation? dev.mysql.com/doc/refman/4.1/en/user-account-management.html Commented Oct 14, 2011 at 6:53
  • For what reason you are using Mysql4 and not Mysql5? Commented Oct 14, 2011 at 6:55
  • @Harry - Customer is still using 4 :( Commented Oct 14, 2011 at 7:01
  • What is the full create user command that you have tried so far? Commented Oct 14, 2011 at 7:09
  • @Tom - It didn't work with a create user, but worked with the grant statement. Commented Oct 14, 2011 at 8:29

1 Answer 1

3

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!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.