Learn how to create a new user in MySQL 8 and grant all privileges on a database.
MySQL 8 introduced performance and security updates. Released in April 2018, MySQL 8 was the first major release since MySQL 5.7 in 2015. With MySQL 5.7 end of support looming in October 2023, it’s a good idea to start upgrade your databases where possible.
Create a new user in MySQL 8
First, create the new user in MySQL 8 using the CREATE USER command like so:
CREATE USER 'username'@'localhost' IDENTIFIED BY 'STR0NG!PAssW0rD';
Grant all privileges in MySQL 8
Next, grant privileges to the user in MySQL 8 using the GRANT command like so:
GRANT ALL ON database-name.* TO 'username'@'localhost';