dbdeployer icon indicating copy to clipboard operation
dbdeployer copied to clipboard

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

Open zzx8170 opened this issue 4 years ago • 9 comments

Describe the bug

deploy single 8.0.26 or 5.7 report ERROR 1045 (28000)

To Reproduce Steps to reproduce the behavior:

#dbdeployer deploy single 8.0

8.0 => 8.0.26

Database installed in $HOME/sandboxes/msb_8_0_26 run 'dbdeployer usage single' for basic instructions' .. sandbox server started cmd: /root/sandboxes/msb_8_0_26/load_grants err: exit status 1 stdout: stderr: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

Expected behavior deploy success

NO Screenshots If applicable, copy and paste the command and the output. Do not use screen shots, unless they add value to the report. Text that can be edited is preferred to graphics.

Environment:

  • OS: el7.x86_64
  • 1.63.1
  • mysql-8.0.26-linux-glibc2.17-x86_64-minimal-rebuild.tar.xz
  • www.mysql.com

Hardware: (if applicable)

  • Free storage
  • Total RAM

Additional context Add any other context about the problem here.

zzx8170 avatar Nov 08 '21 08:11 zzx8170

in script load_grants: $MYSQL -u root -t $VERBOSE_SQL < $SBDIR/$SOURCE_SCRIPT this statment no '-p' result error , how to resolve?

zzx8170 avatar Nov 08 '21 09:11 zzx8170

I have trouble reproducing this issue. Unless you are using options not shown in the description, when load_grants is executed, root does to have a password. In fact, the password is defined by that command. Thus, I am missing information, without which I can't diagnose the problem.

I suggest you remove the sandbox with dbdeployer delete msg_8_0_26, and then run the command again. After that, if it keeps failing, remove the sandbox again and then run the commands:

dbdeployer deploy single 8.0 --skip-load-grants
export SBDEBUG=1
$HOME/sandboxes/msb_8_0_26/load_grants

This should show exactly what is running and the relative errors

datacharmer avatar Nov 08 '21 19:11 datacharmer

as your description, operated as follow:

[root@~]# dbdeployer sandboxes msb_5_7_21 : single 5.7.21 [5721 ]
msb_8_0_26 : single 8.0.26 [8026 18026 ]

[root@~]# dbdeployer delete msb_8_0_26 List of deployed sandboxes: /root/sandboxes/msb_8_0_26 Running /root/sandboxes/msb_8_0_26/send_kill destroy Terminating the server immediately --- kill -9 27119 Running rm -rf /root/sandboxes/msb_8_0_26 Directory /root/sandboxes/msb_8_0_26 deleted [root~]# [root~]# dbdeployer deploy single 8.0 --skip-load-grants

8.0 => 8.0.26

Database installed in $HOME/sandboxes/msb_8_0_26 run 'dbdeployer usage single' for basic instructions' .. sandbox server started

[root@~]# export SBDEBUG=1

[root@~]# $HOME/sandboxes/msb_8_0_26/load_grants ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

zzx8170 avatar Nov 09 '21 02:11 zzx8170

I try other version 1.54.0 , reproducing this issue

zzx8170 avatar Nov 09 '21 02:11 zzx8170

in script load_grants: $MYSQL -u root -t $VERBOSE_SQL < $SBDIR/$SOURCE_SCRIPT

I do follow test:

  1. password is null, command must add '-p', enter may login: [root@zzx-ecs5 ~]# mysql --no-defaults -u root --protocol=tcp -P8026 -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 9 Server version: 8.0.26 MySQL Community Server - GPL

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

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> exit Bye

  1. password is null, but drop '-p' will result error: [root@zzx-ecs5 ~]# mysql --no-defaults -u root --protocol=tcp -P8026 ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

load_grants looks like second example .

zzx8170 avatar Nov 09 '21 08:11 zzx8170

When load_grants run, root is without password. That's how it works. Here's a sample output:

$ dbdeployer deploy single 8.0.26 --skip-load-grants
Database installed in $HOME/sandboxes/msb_8_0_26
run 'dbdeployer usage single' for basic instructions'
. sandbox server started

$ export SBDEBUG=1
$ $HOME/sandboxes/msb_8_0_26/load_grants
--------------
set password='msandbox'
--------------

--------------
create role if not exists R_DO_IT_ALL
--------------

--------------
create role if not exists R_READ_WRITE
--------------

--------------
create role if not exists R_READ_ONLY
--------------

--------------
create role if not exists R_REPLICATION
--------------

--------------
create role if not exists R_CUSTOM
--------------

--------------
grant ALL PRIVILEGES on *.* to R_CUSTOM WITH GRANT OPTION
--------------

--------------
grant all on *.* to R_DO_IT_ALL
--------------

--------------
grant SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,INDEX,ALTER,
    SHOW DATABASES,CREATE TEMPORARY TABLES,LOCK TABLES, EXECUTE
    on *.* to R_READ_WRITE
--------------

--------------
grant SELECT,EXECUTE on *.* to R_READ_ONLY
--------------

--------------
grant REPLICATION SLAVE on *.* to R_REPLICATION
--------------

--------------
create user if not exists msandbox@'127.%' identified by 'msandbox'
--------------

--------------
create user if not exists msandbox@'localhost' identified by 'msandbox'
--------------

--------------
grant R_DO_IT_ALL to msandbox@'127.%'
--------------

--------------
set default role R_DO_IT_ALL to msandbox@'127.%'
--------------

--------------
grant R_DO_IT_ALL to msandbox@'localhost'
--------------

--------------
set default role R_DO_IT_ALL to msandbox@'localhost'
--------------

--------------
create user if not exists msandbox_rw@'localhost' identified by 'msandbox'
--------------

--------------
create user if not exists msandbox_rw@'127.%' identified by 'msandbox'
--------------

--------------
grant R_READ_WRITE to msandbox_rw@'localhost'
--------------

--------------
set default role R_READ_WRITE to msandbox_rw@'localhost'
--------------

--------------
grant R_READ_WRITE to msandbox_rw@'127.%'
--------------

--------------
set default role R_READ_WRITE to msandbox_rw@'127.%'
--------------

--------------
create user if not exists msandbox_ro@'127.%' identified by 'msandbox'
--------------

--------------
create user if not exists msandbox_ro@'localhost' identified by 'msandbox'
--------------

--------------
create user if not exists rsandbox@'127.%' identified by 'rsandbox'
--------------

--------------
grant R_READ_ONLY to msandbox_ro@'127.%'
--------------

--------------
set default role R_READ_ONLY to msandbox_ro@'127.%'
--------------

--------------
grant R_READ_ONLY to msandbox_ro@'localhost'
--------------

--------------
set default role R_READ_ONLY to msandbox_ro@'localhost'
--------------

--------------
grant R_REPLICATION to rsandbox@'127.%'
--------------

--------------
set default role R_REPLICATION to rsandbox@'127.%'
--------------

--------------
create schema if not exists test
--------------

If your system doesn't show what is above, something is wrong with it, although I can't yet figure out what it is

datacharmer avatar Nov 09 '21 08:11 datacharmer

without password but must add '-p' and press 'enter' may login, without '-p' result ERROR 1045 (28000), how to resolve?

zzx8170 avatar Nov 15 '21 03:11 zzx8170

mysql> set password=password(''); Query OK, 0 rows affected, 1 warning (0.00 sec)

[root@ ~]# mysql -uroot -p -S /tmp/mysql57.sock Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1415093 Server version: 5.7.21-log MySQL Community Server (GPL)

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

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> exit Bye [root@ ~]# mysql -uroot -S /tmp/mysql57.sock ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

zzx8170 avatar Nov 15 '21 03:11 zzx8170

[root@ ~]# mysql -uroot -S /tmp/mysql57.sock ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

"using password: YES" means that you're supplying a password from somewhere. Run this command:

my_print_defaults client mysql

If that produces output that includes a line like --password=***** then you probably have a login path (.mylogin.cnf) or .my.cnf with saved credentials.

snoyes avatar Aug 01 '22 20:08 snoyes