Explain how to add a new user account in MySQL.
- New users in MySQL can be added using the CREATE USER syntax.
You can create MySQL accounts in two ways: 1. By using account-management statements intended for creating accounts and establishing their privileges, such as CREATE USER and GRANT. These statements cause the server to make appropriate modifications to the underlying grant tables.
2. By manipulating the MySQL grant tables directly with statements such as INSERT, UPDATE, or DELETE.
- The CREATE USER statement creates new MySQL accounts. It enables account authentication properties to be established.
- To use CREATE USER, you must have the global CREATE USER privilege or the INSERT privilege for the mysql database.
- When the read_only system variable is enabled, CREATE USER additionally requires the SUPER privilege.
- An error occurs if you try to create an account that already exists.
CREATE USER userName IDENTIFIED BY 'passwordString';
- The password is created in an encrypted format.