litespeedtech / ols-docker-env

OpenLiteSpeed Docker Environment

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Create Database script returning DB Access Failed reporting error on fresh install

shankscoder opened this issue · comments

So I'm setting up a fresh WP host on AWS Lightsail using Ubuntu 18.04 with this repo.

Version info:

  • Lightspeed Version: 1.6.13
  • PHP: tlsphp74
  • Docker version: 19.03.12, build 48a66213fe
  • Docker-compose version: 1.26.0, build d445165

This is a default setup after cloning this repo, and editing the .env files and changing the passwords.

After that I ran docker-compose up -d, everything worked as advertised, and I verified this using a index.php file in the localhost site.

When I look to create a new domain, when I try to create a new database, I get a DB Access failed error.

Debugging in the shell scripts a bit, I found the issue in this line:

docker-compose exec mysql su -c "mysql -uroot -p${MYSQL_ROOT_PASSWORD} -e 'status'" >/dev/null 2>&1

Line 83 is checking for a response to the previous command, but it looks like due to the suppression to the output to /dev/null in the Line 82, no output/response is being captured, and the check fails.

When I removed the >/dev/null 2>&1 part, I'm getting the status output of the command in the output and the rest of the database creation works as advertised.

I think this check needs to be done a bit differently to properly check for MySQL output.

commented

HIHI,

From my testing, the output to /dev/null or not shouldn't effect the result, please see,
docker-compose exec mysql su -c "mysql -uroot -ppassword -e 'status'">/dev/null 2>&1; echo $?

0

docker-compose exec mysql su -c "mysql -uroot -pwrongpassword -e 'status'">/dev/null 2>&1; echo $?

1

I also tried to change domain and wordpress password from .env multiple times, it still working for me. Could you share the whole reproduce steps so I can follow and see the issue?

Best

Hi,
Thanks for looking into this.

On my host, when I run

docker-compose exec mysql su -c "mysql -uroot -p${MYSQL_ROOT_PASSWORD} -e 'status'" >/dev/null 2>&1; echo $?

I get a response of

1

even if I use a correct password or wrong password.

This is why its resolving false and failing this check.

I'm not sure why this is behaving differently for you and for me.

Here's my stack setup:

  • OS: Ubuntu 18.04.1 LTS
  • MariaDB version: 10.3.17-MariaDB-1:10.3.17+maria~bionic mariadb.org binary distribution
  • Lightspeed Version: 1.6.13
  • PHP: tlsphp74
  • Docker version: 19.03.12, build 48a66213fe
  • Docker-compose version: 1.26.0, build d445165
commented

Hi @shankscoder,

Interesting, I'll need to bother you again, please try follow command from ols-docker-env folder and share the output

docker-compose exec mysql su -c "mysql -uroot -ppassword -e 'status'"; echo $?

Output example

--------------
mysql  Ver 15.1 Distrib 10.3.17-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2

Connection id:          723
Current database:
Current user:           root@localhost
SSL:                    Not in use
Current pager:          stdout
Using outfile:          ''
Using delimiter:        ;
Server:                 MariaDB
Server version:         10.3.17-MariaDB-1:10.3.17+maria~bionic mariadb.org binary distribution
Protocol version:       10
Connection:             Localhost via UNIX socket
Server characterset:    latin1
Db     characterset:    latin1
Client characterset:    latin1
Conn.  characterset:    latin1
UNIX socket:            /var/run/mysqld/mysqld.sock
Uptime:                 2 days 4 hours 44 min 19 sec

Threads: 7  Questions: 6488  Slow queries: 0  Opens: 29  Flush tables: 1  Open tables: 23  Queries per second avg: 0.034
--------------

0

Please substitute the "password" to your right password.

Hi @Code-Egg ,
Sorry just got the notification on the pending issue.

Yup I'm getting that full output

--------------
mysql  Ver 15.1 Distrib 10.3.17-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2

Connection id:		30412
Current database:
Current user:		root@localhost
SSL:			Not in use
Current pager:		stdout
Using outfile:		''
Using delimiter:	;
Server:			MariaDB
Server version:		10.3.17-MariaDB-1:10.3.17+maria~bionic mariadb.org binary distribution
Protocol version:	10
Connection:		Localhost via UNIX socket
Server characterset:	latin1
Db     characterset:	latin1
Client characterset:	latin1
Conn.  characterset:	latin1
UNIX socket:		/var/run/mysqld/mysqld.sock
Uptime:			15 days 15 hours 55 min 40 sec

Threads: 7  Questions: 2949002  Slow queries: 0  Opens: 30297  Flush tables: 1  Open tables: 106  Queries per second avg: 2.179
--------------

0
commented

Thanks, I really didn't see any issue from your output result. Let's keep this issue open for a while and see if there's any other user who has the same question.

commented

Same problem here.

Plain text passwort -ppassword works, but -p${MYSQL_ROOT_PASSWORD} brings an error:

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

echo ${MYSQL_ROOT_PASSWORD}
works correct:
password

Following solution works:

docker-compose exec -T mysql su -c 'mysql -uroot -p"$MYSQL_ROOT_PASSWORD" -e "status" >/dev/null 2>&1'

commented

Hi @GitHub-Mike ,

I don't see why a variable works in a single quote. For example,

Case 1

A=123; docker-compose exec -T mysql su -c 'touch "$A"'

It returns

touch: cannot touch '': No such file or directory

Case 2

A=123; docker-compose exec -T mysql su -c 'touch $A'

It returns

touch: missing file operand

Below works to me

Case 3

A=123; docker-compose exec -T mysql su -c "touch $A"

Case 4

A=123; docker-compose exec -T mysql su -c "touch '$A'"

Could you confirm the above situation and also try this one?

docker-compose exec -T mysql su -c "mysql -uroot -p'$MYSQL_ROOT_PASSWORD' -e 'status' >/dev/null 2>&1"
commented

@Code-Egg Thanks for your answer.

I don't see why a variable works in a single quote. For example,

Bourne (again) shell has a quote removal stage. This works:

docker-compose exec -T mysql su -c 'echo ${MYSQL_ROOT_PASSWORD}'

Return:

password

Your examples:

Case 1:

A=123; docker-compose exec -T mysql su -c 'touch "$A"'

Return:

touch: cannot touch '': No such file or directory

Case 2:

A=123; docker-compose exec -T mysql su -c 'touch $A'

Return:

touch: missing file operand
Try 'touch --help' for more information.

Case 3:

A=123; docker-compose exec -T mysql su -c "touch $A"

No Return

Case 4:

A=123; docker-compose exec -T mysql su -c "touch '$A'"

No Return

Case 5:

docker-compose exec -T mysql su -c "mysql -uroot -p'$MYSQL_ROOT_PASSWORD' -e 'status' >/dev/null 2>&1"
echo $?

Return:

1

Case 6:

docker-compose exec -T mysql su -c "mysql -uroot -p'$MYSQL_ROOT_PASSWORD' -e 'status'"

Return:

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

commented

HI, you might want to assign a password to the variable first, e.g. MYSQL_ROOT_PASSWORD=xxxxxxx, then run cases 5 and 6. I am still not able to reproduce the issue. If you still have the issue, please raise a ticket to support@litespeedtech.com

commented

Thanks for the late reply. I think this is a specific Windows problem. After switching to wsl or debian the problem did not occur anymore.