C.4 Creating a User

Users in MySQL are created by granting rights. For example, if you grant a user rights to a database, that user is created.

  1. To create a local user, in MySQL Monitor, run the following:

    GRANT ALL PRIVILEGES ON database.table TO username IDENTIFIED BY ’some_pass’ WITH GRANT OPTION;
    

    For example, grant all privileges on naudit.* to audituser grants the default audit user access to the default audit database. For additional information on privileges, see the MySQL documentation.

  2. To create a remote user (a user who can log in from anywhere), run the following:

    GRANT ALL PRIVILEGES ON database.table TO username@'%' IDENTIFIED BY ’some_pass’ WITH GRANT OPTION;
    

    For example, grant all privileges on naudit.* to audituser@'%' enables audituser to remotely access all tables in the naudit database. Optionally, the % wildcard could be replaced with a full or partial DNS name or IP address, for example, audituser@'%.novell.com allows access only from a DNS entry resolving to the .novell.com domain.

  3. When finished, run Flush Privileges; to apply the changes.