Creating users in MySQL
To create a user in MySQL, our user account must have the universal CREATE USER
privilege. In general, no user beyond the database administrator should have this as it allows the user to create, remove, rename, and revoke the privileges of users on the database. We will look at the granting of privileges later in this chapter.
Alternatively, if a user has universal INSERT
privileges, that user can insert a new user and relevant data into the user
table of the mysql
database. This method is prone to error and can endanger the stability of the entire MySQL installation if something goes wrong. Therefore, we do not deal with it here.
When creating a user, we need to specify both the user's name or ID and the user's password. The basic syntax for user creation is as follows:
CREATE USER <userid>;
Breaking the statement up by its token, we first tell MySQL that we want to CREATE
something. Then we clarify the object being created as a USER
account. That account should...