How to create a new user and grant permissions in MySQL and also creating a database ?


sudo mysql
[sudo] password for jeffrin: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.30-1 (Debian)

Copyright (c) 2000, 2022, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> CREATE USER 'jeff'@'localhost' IDENTIFIED WITH authentication_plugin BY 'sixer';
ERROR 1524 (HY000): Plugin 'authentication_plugin' is not loaded
mysql> CREATE USER 'jeff'@'localhost' IDENTIFIED BY 'sixer';
Query OK, 0 rows affected (0.49 sec)

mysql> CREATE DATABASE learning;
Query OK, 1 row affected (0.27 sec)

mysql> UPDATE mysql.user SET Password=PASSWORD('MyNewPass') WHERE User='root';
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '('MyNewPass') WHERE User='root'' at line 1
mysql> UPDATE mysql.user SET Password=PASSWORD('MyNewPass') WHERE User='root';
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '('MyNewPass') WHERE User='root'' at line 1
mysql> GRANT ALL PRIVILEGES ON *.* TO 'jeff'@'localhost' WITH GRANT OPTION;
Query OK, 0 rows affected (0.69 sec)

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.14 sec)

mysql> 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: