afragen / setup-phpunit

Setup PHPUnit for use in Local Lightning
MIT License
20 stars 6 forks source link

Cannot connect to MySQL #3

Open crstauf opened 3 years ago

crstauf commented 3 years ago
$ 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

afragen commented 3 years ago

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

Are you running the commands in the Site Shell?

crstauf commented 3 years ago

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

afragen commented 3 years ago

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

crstauf commented 3 years ago
$ mysql status
ERROR 1049 (42000): Unknown database 'status'
crstauf commented 3 years ago

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
--------------
afragen commented 3 years ago

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?

crstauf commented 3 years ago

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

afragen commented 3 years ago

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.

crstauf commented 3 years ago

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.

afragen commented 3 years ago

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