install mysql 8 ubuntu 22.04

12

Jun

Create a new user MySQL 8 – Ubuntu 22.04

In this tutorial, we’ll guide you through the process of creating a MySQL user with administrative privileges on Ubuntu. By following these steps, you’ll be able to create a user with full access to all databases on your MySQL server.

Access MySQL

Firstly, open your terminal and access MySQL by typing:

sudo mysql

This command will open the MySQL command-line interface with superuser privileges.

Create User

Once you’re in the MySQL command-line interface, you can create a new user with the desired username and password. Type the following command:

CREATE USER 'admin'@'localhost' IDENTIFIED WITH mysql_native_password BY 'mysecretpassword';

Replace 'admin' with your desired username and 'mysecretpassword' with your preferred password.

Grant Privileges

After creating the user, you need to grant all privileges to the user. Execute the following command:

GRANT ALL PRIVILEGES ON *.* TO 'admin'@'localhost' WITH GRANT OPTION;

This command grants all privileges on all databases to the user 'admin' from 'localhost', allowing them to perform any operation on any database.

Flush Privileges

To apply the changes and reload the grant tables, type:

FLUSH PRIVILEGES;

This command ensures that the privileges are updated and available for immediate use.

Exit MySQL

Once you’ve completed the above steps, exit the MySQL command-line interface by typing:

exit;

This will return you to the terminal prompt.

Conclusion

You have successfully created a MySQL user with administrative privileges on your Ubuntu system. This user can now perform administrative tasks such as creating databases, managing users, and more. Make sure to keep your credentials secure and follow best practices for database security. Happy database management!

Leave a Reply

Your email address will not be published. Required fields are marked *

RELATED

Posts