Closed dmorbidi closed 4 years ago
Is your wordpress installation working? I just tried it and it works fine:
devilbox@php-7.4.1 in /shared/httpd/wp/wp $ wp db export
Success: Exported to 'wordpress-2020-01-22-86916e3.sql'.
I'm sorry, you are right. If I consider a classic wp installation it works.
But now I'm using wpstarter and I get this error:
Warning: mysqli_real_connect(): (HY000/2002): No such file or directory in /shared/httpd/shops/shops-website/public/wordpress/wp-includes/wp-db.php on line 1612
Do you have any suggestion? I'm trying to understand where is the problem.
What is the code in /shared/httpd/shops/shops-website/public/wordpress/wp-includes/wp-db.php
on line 1612
?
This:
mysqli_real_connect( $this->dbh, $host, $this->dbuser, $this->dbpassword, null, $port, $socket, $client_flags );
But now I'm using wpstarter and I get this error:
Tried to reproduce, but I am getting this:
devilbox@php-7.4.1 in /shared/httpd/wp/wp $ wp wpstarter
Error: 'wpstarter' is not a registered wp command. See 'wp help' for available commands.
Wp starter is not a wp-cli command. check this: https://wecodemore.github.io/wpstarter/docs/quick-start.html .
Wp starter let to create a wordpress env directly from composer.
Currently after installing everything (composer install) under project dir in devil box, I have this situation: -- data/www/my-project/prj_name/public/wordpress -- data/www/my-project/prj_name/public/wp-content -- data/www/my-project/prj_name/public/wp-config.php -- data/www/my-project/prj_name/public/index.php
I created htdocs dir as a link to the data/www/my-project/prj_name/public dir.
And if I try to perform
wp db export
I'm gettin the error mysqldump: Got error: 2002: "Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)" when trying to connect
If instead I go in the site I get this error: Warning: mysqli_real_connect(): (HY000/2002): No such file or directory in /shared/httpd/shops/shops-website/public/wordpress/wp-includes/wp-db.php on line 1612
Can you add the exact commands issued and also the directory from where you issued them.
devilbox@php-7.3.13 in /shared/httpd/shops/htdocs $ wp db export
right before that: ln -s shops-website/public/ htdocs
I actually meant how you installed it exactly, as this command works on my machine (discussed above)
Ok I set the devilbox as explained in the docs. I also created a standard wordpress site as explained in doc and all was fine.
Then I created another wordpress project, but this time instead of cloning wordpress.git I cloned a project of mine which works with wp starter and I did :
devilbox@php-7.3.13 in /shared/httpd/shops/shops-website $ composer install devilbox@php-7.3.13 in /shared/httpd/shops $ ln -s shops-website/public/ htdocs devilbox@php-7.3.13 in /shared/httpd/shops/htdocs $ wp db export
And got mysqldump: Got error: 2002: "Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)" when trying to connect
If instead I go in the site I get this error: Warning: mysqli_real_connect(): (HY000/2002): No such file or directory in /shared/httpd/shops/shops-website/public/wordpress/wp-includes/wp-db.php on line 1612
I would assume that the wp-config.php
has wrong settings to connect to the database.
the mysqld.sock line implies that its trying to connect to a mysql instance on that same host, not through the networking stack, but through a local socket.
That would not use any of the port forwarding Devilbox has setup so that the php container can access the mysql container.
@dmorbidi What host name / address is in your config to connect to the database?
Hey @cytopia you were right: was a configuration issue.
wpstarter read configuration on .env file and so updates the wp-config.php accordingly. But also it creates a env.cache.php file and uses always the info stored there...so the wrong db credentials were always used.
I deleted that file and he read the .env again grabbing the actual values...and it worked. Thanks a lot for the support. And thanks also to @science695 .
ISSUE TYPE
SUMMARY
The docs states that wp-cli can be used but this seems not really true since if we try for example to export a database:
wp db export
We got: "Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' "
Seems this is due to how devilbox works. And if so, is really a pity to loose these wp-cli functionalities. Or am I missing something?
Goal
In order to align the docs to the current situation would be very useful to access database through wp-cli. Otherwise, maybe the statement in the docs should be properly updated.