MariaDB setting : Access denied for user 'root'@'ma' (using password: YES)

5.4k Views Asked by At

[update] I solve the problem by :

SET PASSWORD FOR 'root'@'ma'=PASSWORD('pass');

And I still have a question want to ask:
should I set password for 127.0.0.1 and ::1 ???
What's these two root user is???

enter image description here

[original question] I have a server I can log in DB on the server From my computer,I can access ,too.
BUT WHEN I put the code on tomcat on that server
I run the code and got error : Access denied for user 'root'@'master' (using password: YES)

I guess it's because my code is jdbc:mysql://192.168.xx.xx:3306/project not jdbc:mysql://127.0.0.1:3306/project

How can I fix this problem?? What should I set ?

1

There are 1 best solutions below

1
On

It's a question of GRANTs:

For connecting to an IP address or hostname:

GRANT ... TO 'user'@'192.2.3.4' ...;
GRANT ... TO 'user'@'host.name' ...;

For connecting to localhost (alias 127.0.0.1) -- That is, when the client is on the same machine as the server:

GRANT ... TO 'user'@'localhost' ...;

(Actually, you can use either technique to connect from the same server.)