1

How do I grant permissions to users in MySQL?

This is the order in which I tried:

  1. First, connect from EC2 SERVER to MYSQL CLIENT RDS.
  2. After connecting, MYSQL created a user to give you permission.
  3. An error occurs when giving the user permission.

My attempt:

 mysql> CREATE USER 'injekim'@'125.128.63.112' IDENTIFIED BY 'k12345678!!';
    Query OK, 0 rows affected (0.02 sec)

mysql> GRANT ALL PRIVILEGES ON *.* TO 'injekim'@'125.128.63.112' WITH GRANT OPTION;
ERROR 1045 (28000): Access denied for user 'root'@'%' (using password: YES)


ERROR 1045 (28000): Access denied for user 'root'@'%' (using password: YES)

Also, I found similar error information in stackoverflow, but I couldn't solve it.

MySQL ERROR 1045 (28000): Access denied for user 'bill'@'localhost' (using password: YES)

How can I authorize the user who created it?

user207421
  • 305,947
  • 44
  • 307
  • 483
Python-97
  • 288
  • 2
  • 13

1 Answers1

0

It looks like you are not logged into the host machine. To use the root user, you should actually be logged into the machine (ssh or rdp) that is hosting the MySQL server.

Example, let's say I am setting at my Mac but need to give a new user access to a MySQL database that is running on a server with an IP address of 192.168.1.10. Assuming it's a Linux server I would ssh to the server from my Mac's terminal by running: ssh myuser@192.168.1.10

You can now either:

  1. Log into MySQL as root by running: mysql -u root -p (you will be prompted for the password)

Or,

  1. You could become the root user. In my case, I would run the following: sudo su. Now that you are the root user, you can log into MySQL by running: mysql -p

If you need an example in a Windows environment, let me know. It will be the same basic idea, but using RDP instead of ssh. From your local machine, get a session on the actual server running MySQL and then log into MySQL as root from the server.

Doyle B
  • 104
  • 6