IoTKETI / Mobius

oneM2M IoT Server Platform
http://developers.iotocean.org/archives/module/mobius
BSD 3-Clause "New" or "Revised" License
134 stars 87 forks source link

Access denied for user 'root'@'localhost' (using password: NO) #30

Open mKay00 opened 4 years ago

mKay00 commented 4 years ago

I used Mobius_Docker, but I can't get it to work. When it's started, I get repeatedly the following output

node_1  | GET : /Mobius
node_1  |
node_1  | GET : /Mobius
node_1  | get_resource_from_url (hokpoASd) - /Mobius: 2.846ms
node_1  | get_resource_from_url (z_wpz8jS) - /Mobius: 3.322ms
node_1  | {"rsc":"5000","ri":"GET-/Mobius-{\"fu\":2,\"rcn\":1,\"rt\":3}","msg":"database error"}
node_1  | Target CSE(localhost) is not ready
node_1  | Target CSE(localhost) is not ready
node_1  | {"rsc":"5000","ri":"GET-/Mobius-{\"fu\":2,\"rcn\":1,\"rt\":3}","msg":"database error"}

Since the message says database error, I looked what the database does and at the end of the database setup it says

db_1    | 2020-01-16T15:00:53.686717Z 2 [Note] Access denied for user 'root'@'localhost' (using password: NO)

So, I am wondering how I could fix the issue. I already tried it on another PC, on Linux and Windows and also followed the steps for manual installation from the installation guide. I always get a database error. I also tried different solutions I found on the internet for the Access denied error, but nothing seems to work for me.

I would really appreciate some help here, since I ran out of options to try.

The version of MySQL is 5.7.28.

hsebs commented 4 years ago

Mysql returns "Access denied for user" when authentication plugin is wrong. Mobius uses mysql_native_password as authentication plugin.

Check authentication plugin of mysql account. SELECT user,plugin,host FROM mysql.user;

lovele0107 commented 4 years ago

Hi, I used also the Mobius_Docker and got the same error. connecting to mysql account , I checked the plugin is mysql_native_password. Could you please help ? Thanks.

hsebs commented 4 years ago

@lovele0107 Try flush privileges;

lovele0107 commented 4 years ago

Hi .
I went to mysql using command: sudo docker exec -it mobius_docker_db_1 mysql -u root -p then I have tried : flush privileges, but it does not solve the issue.

mKay00 commented 4 years ago

Same for me. I checked the authentication plugin and tried flush privileges. The plugins are mysql_native_password: image

and flush privileges shows OK: image

But I still get access denied afterwards, when I docker-compose up

edit: When I use docker-compose up, it says Recreating mobius_docker_db_1, does this mean that the flush privileges doesn't have an effect, because it always creates a new image? If so, what would be the correct way to do this?

hsebs commented 4 years ago

I installed Mobius Docker and got a same result. I found that mysql on mobius_docker_db_1 does not have any table.

image

hsebs commented 4 years ago

@mKay00 @lovele0107

I found the cause. IoTKETI removed sql directory from Mobius but Mobius_Docker still uses it.

Enter

mkdir sql
cp ./mobius/mobiusdb.sql ./sql/mobiusdb.sql

after Mobius_Docker Installation step 4.

It will works well.

image

P.S. MySQL stll returns access denied error, but I don't know who try to access.

lovele0107 commented 4 years ago

HI , I confirm it is working now. The rights of the sql file would need to be changed in order to be in the same user group. ( or do not use sudo for copying the sql file) Thank you very much for your prompt reply to this issue.

mKay00 commented 4 years ago

Thank you, although I am still getting Access denied for user 'root'@'localhost', it works now.

hsebs commented 4 years ago

@mKay00 I found the cause. healthcheck command of Mobius_Docker is wrong.

image

Command should include password.

image

Change line 18 of docker-compose.yml in Mobius Docker from

test: ["CMD", "mysqladmin" ,"ping", "-h", "localhost"]

to

test: ["CMD", "mysqladmin" , "--password=dksdlfduq2","ping", "-h", "localhost"]