Account management in MySQL 8
As the name implies, this topic describes how to manage user accounts in MySQL 8. We will describe how to add new accounts, how to remove accounts, how to define usernames and passwords for the accounts, and more.
Add and remove user accounts
MySQL 8 provides two different ways to create accounts:
- Using account management statements: These statements are used to create users and set their privileges; for example, with
CREATE USER
andGRANT
statements, which inform the server to perform modifications on the grant table
- Using manipulation of grant tables: Using
INSERT
,UPDATE
, andDELETE
statements, we can manipulate the grant table
Out of these two approaches, account management statements are preferable, because they are more concise and less error-prone. Now, let's see an example of using the commands:
#1 mysql> CREATE USER 'user1'@'localhost' IDENTIFIED BY 'user1_password'; #2 mysql> GRANT ALL PRIVILEGES ON *.* TO 'user1'@'localhost' WITH GRANT OPTION; #3...