setup-phpunit icon indicating copy to clipboard operation
setup-phpunit copied to clipboard

Cannot connect to MySQL

Open crstauf opened this issue 4 years ago • 10 comments

$ bash ../setup-phpunit.sh
...
Checking if database wordpress_test exists
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
Creating database wordpress_test
mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)'
Check that mysqld is running and that the socket: '/tmp/mysql.sock' exists!

Local: 6.0.0+5444 Site opens and operates fine in browser

crstauf avatar Jul 07 '21 23:07 crstauf

I just tested the script(s) again and had no issues.

Are you running the commands in the Site Shell?

afragen avatar Jul 08 '21 00:07 afragen

@afragen Yes, tried both in case I had forgotten. :wink:

crstauf avatar Jul 08 '21 01:07 crstauf

In the Site Shell what does the command mysql status show?

afragen avatar Jul 08 '21 04:07 afragen

$ mysql status
ERROR 1049 (42000): Unknown database 'status'

crstauf avatar Jul 08 '21 04:07 crstauf

Possible this is what you're looking for:

$ mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 74
Server version: 8.0.16 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> status
--------------
mysql  Ver 8.0.16 for macos10.14 on x86_64 (MySQL Community Server - GPL)

Connection id:		74
Current database:	
Current user:		root@localhost
SSL:			Not in use
Current pager:		stdout
Using outfile:		''
Using delimiter:	;
Server version:		8.0.16 MySQL Community Server - GPL
Protocol version:	10
Connection:		Localhost via UNIX socket
Server characterset:	utf8
Db     characterset:	utf8
Client characterset:	utf8mb4
Conn.  characterset:	utf8mb4
UNIX socket:		/Users/caleb/Library/Application Support/Local/run/XXXXXX/mysql/mysqld.sock
Uptime:			5 hours 53 min 18 sec

Threads: 2  Questions: 3900  Slow queries: 0  Opens: 529  Flush tables: 3  Open tables: 435  Queries per second avg: 0.183
--------------

crstauf avatar Jul 08 '21 05:07 crstauf

It is and now I really don't know why it's not working for you. Is it possible that a restart of your Mac might fix something?

afragen avatar Jul 08 '21 08:07 afragen

Yep, that was my debugging attempt: issue persisted after reboot.

crstauf avatar Jul 08 '21 12:07 crstauf

Not sure what to tell you. I know "it works on my machine" is not a satisfactory answer.

You might look specifically at the database creation code and see if you can figure out why it's not work for you.

afragen avatar Jul 08 '21 13:07 afragen

Okay, then I imagine it's some sort of permissions issue: I have to run the command as sudo bash ../setup-phpunit.sh (because I get /tmp/wordpress.tar.gz: Permission denied), and I wonder if /tmp/mysql.sock is not accessible by root.

crstauf avatar Jul 08 '21 13:07 crstauf

I'm glad you're figuring it out. 😂

afragen avatar Jul 08 '21 17:07 afragen