MySQL 8: Create user and grant all privileges on database

By Dillon Smart · · · 0 Comments

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';
Create user in MySQL 8

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';

MySQL

0 Comment

Was this helpful? Leave a comment!

This site uses Akismet to reduce spam. Learn how your comment data is processed.

The ULTIMATE guide to setup Windows Subsystem for Linux (WSL) with Ubuntu, Apache2, MySQL and PHP

Updated 16th August 2022

Windows is now good for development! Yes! All thanks to Windows Subsystem for Linux (WSL). No more WAMP or Xampp, WSL can do everything you need. In this ultimate guide to setup Windows Subsystem for Linux with Ubuntu, Apache2, MySQL, and PHP we will cover: What is Windows Subsystem for Linux? Setting up Windows Subsystem

How to grant full privileges to a user in MySQL

Updated 16th August 2022

After setting up a lamp stack development environement with phpmyadmin locally on Linux you may notice that your phpmyadmin user (or other user name) doesn’t have the correct privileges to create new databases. To use the phpmyadmin user to create new databases and users for those databases you need to grant full privileges to the

JDBC Connector Communication link failure error to MySQL

Updated 3rd January 2024

Are you having trouble connecting to a MySQL database through JDBC Connector in a database management tool such as DBeaver Community Edition? DBeaver fails to connect to a local MySQL database with the error “Communication link failure the last packet sent successfully to the server was 0 milliseconds ago“. Here is a breakdown of this