SQLSTATE[HY000] [2002] No such file or directory error The Next CEO of Stack OverflowError...
% symbol leads to superlong (forever?) compilations
Science fiction (dystopian) short story set after WWIII
Opposite of a diet
Visit to the USA with ESTA approved before trip to Iran
Increase performance creating Mandelbrot set in python
Anatomically Correct Mesopelagic Aves
Why didn't Theresa May consult with Parliament before negotiating a deal with the EU?
How to write the block matrix in LaTex?
What is the point of a new vote on May's deal when the indicative votes suggest she will not win?
Putting a 2D region plot under a 3D plot
What is meant by a M next to a roman numeral?
How to use tikz in fbox?
Too much space between section and text in a twocolumn document
Why doesn't a table tennis ball float on the surface? How do we calculate buoyancy here?
What does this shorthand mean?
How do spells that require an ability check vs. the caster's spell save DC work?
How to write papers efficiently when English isn't my first language?
Why do professional authors make "consistency" mistakes? And how to avoid them?
Is HostGator storing my password in plaintext?
Can the Reverse Gravity spell affect the Meteor Swarm spell?
I believe this to be a fraud - hired, then asked to cash check and send cash as Bitcoin
Why do remote companies require working in the US?
Implement the Thanos sorting algorithm
Is it my responsibility to learn a new technology in my own time my employer wants to implement?
SQLSTATE[HY000] [2002] No such file or directory error
The Next CEO of Stack OverflowError Processing Request: SQLSTATE[HY000] [2002] No such file or directory"Socket Server and Mage.php base class - MySQL server has gone awayPDO Exception error on indexIf there is one item left in inventory I get SQLSTATE ERRORSQLSTATE[42S22]: Column not found: 1054 Unknown column 'session_id' in 'field list'F5 key Flood and “Error log record number reporting” pageError logging into magento admin, magento-1.9Magento is ignoring host in local.xml and attempting to connect via Unix SocketMigration Error - Exception: SQLSTATE[HY000] [2002]Error Processing Request: SQLSTATE[HY000] [2002] No such file or directory"Shop crashes SQLSTATE[HY000] in error reports
There has been an error processing your request
SQLSTATE[HY000] [2002] No such file or directory
Getting the above error please someone provide me solution to solve this.
mysql
add a comment |
There has been an error processing your request
SQLSTATE[HY000] [2002] No such file or directory
Getting the above error please someone provide me solution to solve this.
mysql
I've fixed it by changing connection string, make sure that your mysql is on and you have all the tables exists in the database.
– Touqeer Shafi
Jun 5 '15 at 15:03
add a comment |
There has been an error processing your request
SQLSTATE[HY000] [2002] No such file or directory
Getting the above error please someone provide me solution to solve this.
mysql
There has been an error processing your request
SQLSTATE[HY000] [2002] No such file or directory
Getting the above error please someone provide me solution to solve this.
mysql
mysql
edited Jan 13 '15 at 7:55
dh47
1,68811431
1,68811431
asked Jan 13 '15 at 6:05
codercoder
37321126
37321126
I've fixed it by changing connection string, make sure that your mysql is on and you have all the tables exists in the database.
– Touqeer Shafi
Jun 5 '15 at 15:03
add a comment |
I've fixed it by changing connection string, make sure that your mysql is on and you have all the tables exists in the database.
– Touqeer Shafi
Jun 5 '15 at 15:03
I've fixed it by changing connection string, make sure that your mysql is on and you have all the tables exists in the database.
– Touqeer Shafi
Jun 5 '15 at 15:03
I've fixed it by changing connection string, make sure that your mysql is on and you have all the tables exists in the database.
– Touqeer Shafi
Jun 5 '15 at 15:03
add a comment |
9 Answers
9
active
oldest
votes
If your server listed in app/etc/local.xml
is localhost
and this error appears in Magento's error log, but Magento still is running ok, then mysql was restarted and the socket /tmp/mysql.sock
or whatever socket file is set up in my.cnf
temporarily disappeared.
Because it's missing, the PDO mysql connector reports SQLSTATE[HY000] [2002] No such file or directory
If you are continually getting this error thrown and have no access to Magento aside from the Exception Error page, then mysql has crashed completely and you need your hosting provider to find out why and restart mysql.
add a comment |
I had the same issue while installing Magento 2.1.0 with PHP 7.0.13.
I could resolve this issue by setting the database hostname as 127.0.0.1 instead of localhost .
add a comment |
set the database hostname as 127.0.0.1 instead of localhost.
add a comment |
This can also happen if ur filesystem is full ...
df -h 1st ...ofcourse, mostly u shud get alerts before that...
mysqld wont be running normally, and would be in a "safe" mode
HTH
SNS
add a comment |
Make sure you edit your app/etc/local.xml properly.
If you have no prefixes for your tables make sure the proper line is:
<table_prefix><![CDATA[]]></table_prefix>
NOT
<table_prefix>{{db_prefix}}</table_prefix>
add a comment |
This is commonly caused by a different instance of PHP being used by the PHP command line compared to the web server. In particular, mysql.sock
might be misconfigured if this is the case.
To determine whether or not you’re using one instance of PHP:
- Log in to your Magento server.
Enter the following command:
php -i | grep 'php.ini'
This determines the settings used by the PHP command-line interface (CLI). Note where php.ini
is located.
- If you haven’t already done so, set up a
phpinfo.php
on your web server. - Compare the value of Loaded Configuration File from
phpinfo.php
with the one fromphp -i
.
phpinfo.php
shows the php.ini
file used by your web server. If it’s different from what's in PHP's php.ini
, you must make all PHP settings consistent for both the PHP CLI and the web server.
For additional details, consult the documentation provided with your web server.
This can happen - I think I am facing this right now. But why? Any specific ideas on what to check in these ini files?
– VladFr
Jan 23 '17 at 13:57
4
Rather You may provide some courtesy to this page devdocs.magento.com/guides/v2.0/install-gde/trouble/php/…
– Shan
Feb 27 '17 at 12:03
add a comment |
I have several versions of PHP available to me via the shell - typing php and pressing tab shows which ones my autocomplete knows about.
For me, PHP 5.4, 5.5 and 5.6 were all working fine, but PHP 7 wasn't finding the mysql.sock, and was crashing with the "SQLSTATE[HY000] [2002] No such file or directory error" discussed in this question.
# Prints [ok]
echo "<?php print(new mysqli('localhost', 'root', 'root', 'mysql') ? '[ok]' : '[error]').PHP_EOL; ?>" | php-5.6.20
# Prints [error] and shows a warning
echo "<?php print(new mysqli('localhost', 'root', 'root', 'mysql') ? '[ok]' : '[error]').PHP_EOL; ?>" | php-7.0.8
To see where your mysql server has its socket, use this command:
cat /etc/mysql/my.cnf | grep socket
In my case, with Percona Mysql installed in my vagrant system the sock socket file happened to live here:
/var/run/mysqld/mysqld.sock
(notice that it is called mysqld not simply mysql)
I have several versions of php to choose from and these commands showed me which ones had issues and which ones were fine:
The answer for me was simply to include code in the vagrant provisioner script to create a symlink between /tmp/mysql.sock and /var/run/mysqld/mysqld.sock
if [ ! -L /tmp/mysql.sock ]; then
echo "Creating symbolic link for php 7 to connect to mysql.sock"
ln -s /var/run/mysqld/mysqld.sock /tmp/mysql.sock
fi
With the new symlink in place, the test script given before now works perfectly for all versions of PHP and I can use localhost in my code instead of having to give the 127.0.0.1 IP address.
add a comment |
I get the same error "SQLSTATE[HY000] [2002] No such file or directory". And found that MySQL service was stopped. I started my MySQL service and its working fine.
add a comment |
I had this same issue, and I used below to select which php have to use. /usr/local/etc/php/7.2/bin/php bin/magento setup:di:compile
See official docs:
SQLSTATE[HY000] [2002] No such file or directory
New contributor
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "479"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f51948%2fsqlstatehy000-2002-no-such-file-or-directory-error%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
9 Answers
9
active
oldest
votes
9 Answers
9
active
oldest
votes
active
oldest
votes
active
oldest
votes
If your server listed in app/etc/local.xml
is localhost
and this error appears in Magento's error log, but Magento still is running ok, then mysql was restarted and the socket /tmp/mysql.sock
or whatever socket file is set up in my.cnf
temporarily disappeared.
Because it's missing, the PDO mysql connector reports SQLSTATE[HY000] [2002] No such file or directory
If you are continually getting this error thrown and have no access to Magento aside from the Exception Error page, then mysql has crashed completely and you need your hosting provider to find out why and restart mysql.
add a comment |
If your server listed in app/etc/local.xml
is localhost
and this error appears in Magento's error log, but Magento still is running ok, then mysql was restarted and the socket /tmp/mysql.sock
or whatever socket file is set up in my.cnf
temporarily disappeared.
Because it's missing, the PDO mysql connector reports SQLSTATE[HY000] [2002] No such file or directory
If you are continually getting this error thrown and have no access to Magento aside from the Exception Error page, then mysql has crashed completely and you need your hosting provider to find out why and restart mysql.
add a comment |
If your server listed in app/etc/local.xml
is localhost
and this error appears in Magento's error log, but Magento still is running ok, then mysql was restarted and the socket /tmp/mysql.sock
or whatever socket file is set up in my.cnf
temporarily disappeared.
Because it's missing, the PDO mysql connector reports SQLSTATE[HY000] [2002] No such file or directory
If you are continually getting this error thrown and have no access to Magento aside from the Exception Error page, then mysql has crashed completely and you need your hosting provider to find out why and restart mysql.
If your server listed in app/etc/local.xml
is localhost
and this error appears in Magento's error log, but Magento still is running ok, then mysql was restarted and the socket /tmp/mysql.sock
or whatever socket file is set up in my.cnf
temporarily disappeared.
Because it's missing, the PDO mysql connector reports SQLSTATE[HY000] [2002] No such file or directory
If you are continually getting this error thrown and have no access to Magento aside from the Exception Error page, then mysql has crashed completely and you need your hosting provider to find out why and restart mysql.
edited Jan 13 '15 at 7:55
answered Jan 13 '15 at 7:49
Fiasco LabsFiasco Labs
6,67841944
6,67841944
add a comment |
add a comment |
I had the same issue while installing Magento 2.1.0 with PHP 7.0.13.
I could resolve this issue by setting the database hostname as 127.0.0.1 instead of localhost .
add a comment |
I had the same issue while installing Magento 2.1.0 with PHP 7.0.13.
I could resolve this issue by setting the database hostname as 127.0.0.1 instead of localhost .
add a comment |
I had the same issue while installing Magento 2.1.0 with PHP 7.0.13.
I could resolve this issue by setting the database hostname as 127.0.0.1 instead of localhost .
I had the same issue while installing Magento 2.1.0 with PHP 7.0.13.
I could resolve this issue by setting the database hostname as 127.0.0.1 instead of localhost .
answered Dec 2 '16 at 12:58
JinoJino
37124
37124
add a comment |
add a comment |
set the database hostname as 127.0.0.1 instead of localhost.
add a comment |
set the database hostname as 127.0.0.1 instead of localhost.
add a comment |
set the database hostname as 127.0.0.1 instead of localhost.
set the database hostname as 127.0.0.1 instead of localhost.
answered Dec 20 '16 at 17:59
guestguest
411
411
add a comment |
add a comment |
This can also happen if ur filesystem is full ...
df -h 1st ...ofcourse, mostly u shud get alerts before that...
mysqld wont be running normally, and would be in a "safe" mode
HTH
SNS
add a comment |
This can also happen if ur filesystem is full ...
df -h 1st ...ofcourse, mostly u shud get alerts before that...
mysqld wont be running normally, and would be in a "safe" mode
HTH
SNS
add a comment |
This can also happen if ur filesystem is full ...
df -h 1st ...ofcourse, mostly u shud get alerts before that...
mysqld wont be running normally, and would be in a "safe" mode
HTH
SNS
This can also happen if ur filesystem is full ...
df -h 1st ...ofcourse, mostly u shud get alerts before that...
mysqld wont be running normally, and would be in a "safe" mode
HTH
SNS
answered Mar 8 '17 at 11:05
shaheen shahshaheen shah
211
211
add a comment |
add a comment |
Make sure you edit your app/etc/local.xml properly.
If you have no prefixes for your tables make sure the proper line is:
<table_prefix><![CDATA[]]></table_prefix>
NOT
<table_prefix>{{db_prefix}}</table_prefix>
add a comment |
Make sure you edit your app/etc/local.xml properly.
If you have no prefixes for your tables make sure the proper line is:
<table_prefix><![CDATA[]]></table_prefix>
NOT
<table_prefix>{{db_prefix}}</table_prefix>
add a comment |
Make sure you edit your app/etc/local.xml properly.
If you have no prefixes for your tables make sure the proper line is:
<table_prefix><![CDATA[]]></table_prefix>
NOT
<table_prefix>{{db_prefix}}</table_prefix>
Make sure you edit your app/etc/local.xml properly.
If you have no prefixes for your tables make sure the proper line is:
<table_prefix><![CDATA[]]></table_prefix>
NOT
<table_prefix>{{db_prefix}}</table_prefix>
edited Aug 3 '15 at 19:41
brentwpeterson
4,32653475
4,32653475
answered Aug 3 '15 at 19:18
AlexLAlexL
166110
166110
add a comment |
add a comment |
This is commonly caused by a different instance of PHP being used by the PHP command line compared to the web server. In particular, mysql.sock
might be misconfigured if this is the case.
To determine whether or not you’re using one instance of PHP:
- Log in to your Magento server.
Enter the following command:
php -i | grep 'php.ini'
This determines the settings used by the PHP command-line interface (CLI). Note where php.ini
is located.
- If you haven’t already done so, set up a
phpinfo.php
on your web server. - Compare the value of Loaded Configuration File from
phpinfo.php
with the one fromphp -i
.
phpinfo.php
shows the php.ini
file used by your web server. If it’s different from what's in PHP's php.ini
, you must make all PHP settings consistent for both the PHP CLI and the web server.
For additional details, consult the documentation provided with your web server.
This can happen - I think I am facing this right now. But why? Any specific ideas on what to check in these ini files?
– VladFr
Jan 23 '17 at 13:57
4
Rather You may provide some courtesy to this page devdocs.magento.com/guides/v2.0/install-gde/trouble/php/…
– Shan
Feb 27 '17 at 12:03
add a comment |
This is commonly caused by a different instance of PHP being used by the PHP command line compared to the web server. In particular, mysql.sock
might be misconfigured if this is the case.
To determine whether or not you’re using one instance of PHP:
- Log in to your Magento server.
Enter the following command:
php -i | grep 'php.ini'
This determines the settings used by the PHP command-line interface (CLI). Note where php.ini
is located.
- If you haven’t already done so, set up a
phpinfo.php
on your web server. - Compare the value of Loaded Configuration File from
phpinfo.php
with the one fromphp -i
.
phpinfo.php
shows the php.ini
file used by your web server. If it’s different from what's in PHP's php.ini
, you must make all PHP settings consistent for both the PHP CLI and the web server.
For additional details, consult the documentation provided with your web server.
This can happen - I think I am facing this right now. But why? Any specific ideas on what to check in these ini files?
– VladFr
Jan 23 '17 at 13:57
4
Rather You may provide some courtesy to this page devdocs.magento.com/guides/v2.0/install-gde/trouble/php/…
– Shan
Feb 27 '17 at 12:03
add a comment |
This is commonly caused by a different instance of PHP being used by the PHP command line compared to the web server. In particular, mysql.sock
might be misconfigured if this is the case.
To determine whether or not you’re using one instance of PHP:
- Log in to your Magento server.
Enter the following command:
php -i | grep 'php.ini'
This determines the settings used by the PHP command-line interface (CLI). Note where php.ini
is located.
- If you haven’t already done so, set up a
phpinfo.php
on your web server. - Compare the value of Loaded Configuration File from
phpinfo.php
with the one fromphp -i
.
phpinfo.php
shows the php.ini
file used by your web server. If it’s different from what's in PHP's php.ini
, you must make all PHP settings consistent for both the PHP CLI and the web server.
For additional details, consult the documentation provided with your web server.
This is commonly caused by a different instance of PHP being used by the PHP command line compared to the web server. In particular, mysql.sock
might be misconfigured if this is the case.
To determine whether or not you’re using one instance of PHP:
- Log in to your Magento server.
Enter the following command:
php -i | grep 'php.ini'
This determines the settings used by the PHP command-line interface (CLI). Note where php.ini
is located.
- If you haven’t already done so, set up a
phpinfo.php
on your web server. - Compare the value of Loaded Configuration File from
phpinfo.php
with the one fromphp -i
.
phpinfo.php
shows the php.ini
file used by your web server. If it’s different from what's in PHP's php.ini
, you must make all PHP settings consistent for both the PHP CLI and the web server.
For additional details, consult the documentation provided with your web server.
edited Dec 2 '16 at 13:31
7ochem
5,81493768
5,81493768
answered Dec 2 '16 at 13:12
gelanivishalgelanivishal
805620
805620
This can happen - I think I am facing this right now. But why? Any specific ideas on what to check in these ini files?
– VladFr
Jan 23 '17 at 13:57
4
Rather You may provide some courtesy to this page devdocs.magento.com/guides/v2.0/install-gde/trouble/php/…
– Shan
Feb 27 '17 at 12:03
add a comment |
This can happen - I think I am facing this right now. But why? Any specific ideas on what to check in these ini files?
– VladFr
Jan 23 '17 at 13:57
4
Rather You may provide some courtesy to this page devdocs.magento.com/guides/v2.0/install-gde/trouble/php/…
– Shan
Feb 27 '17 at 12:03
This can happen - I think I am facing this right now. But why? Any specific ideas on what to check in these ini files?
– VladFr
Jan 23 '17 at 13:57
This can happen - I think I am facing this right now. But why? Any specific ideas on what to check in these ini files?
– VladFr
Jan 23 '17 at 13:57
4
4
Rather You may provide some courtesy to this page devdocs.magento.com/guides/v2.0/install-gde/trouble/php/…
– Shan
Feb 27 '17 at 12:03
Rather You may provide some courtesy to this page devdocs.magento.com/guides/v2.0/install-gde/trouble/php/…
– Shan
Feb 27 '17 at 12:03
add a comment |
I have several versions of PHP available to me via the shell - typing php and pressing tab shows which ones my autocomplete knows about.
For me, PHP 5.4, 5.5 and 5.6 were all working fine, but PHP 7 wasn't finding the mysql.sock, and was crashing with the "SQLSTATE[HY000] [2002] No such file or directory error" discussed in this question.
# Prints [ok]
echo "<?php print(new mysqli('localhost', 'root', 'root', 'mysql') ? '[ok]' : '[error]').PHP_EOL; ?>" | php-5.6.20
# Prints [error] and shows a warning
echo "<?php print(new mysqli('localhost', 'root', 'root', 'mysql') ? '[ok]' : '[error]').PHP_EOL; ?>" | php-7.0.8
To see where your mysql server has its socket, use this command:
cat /etc/mysql/my.cnf | grep socket
In my case, with Percona Mysql installed in my vagrant system the sock socket file happened to live here:
/var/run/mysqld/mysqld.sock
(notice that it is called mysqld not simply mysql)
I have several versions of php to choose from and these commands showed me which ones had issues and which ones were fine:
The answer for me was simply to include code in the vagrant provisioner script to create a symlink between /tmp/mysql.sock and /var/run/mysqld/mysqld.sock
if [ ! -L /tmp/mysql.sock ]; then
echo "Creating symbolic link for php 7 to connect to mysql.sock"
ln -s /var/run/mysqld/mysqld.sock /tmp/mysql.sock
fi
With the new symlink in place, the test script given before now works perfectly for all versions of PHP and I can use localhost in my code instead of having to give the 127.0.0.1 IP address.
add a comment |
I have several versions of PHP available to me via the shell - typing php and pressing tab shows which ones my autocomplete knows about.
For me, PHP 5.4, 5.5 and 5.6 were all working fine, but PHP 7 wasn't finding the mysql.sock, and was crashing with the "SQLSTATE[HY000] [2002] No such file or directory error" discussed in this question.
# Prints [ok]
echo "<?php print(new mysqli('localhost', 'root', 'root', 'mysql') ? '[ok]' : '[error]').PHP_EOL; ?>" | php-5.6.20
# Prints [error] and shows a warning
echo "<?php print(new mysqli('localhost', 'root', 'root', 'mysql') ? '[ok]' : '[error]').PHP_EOL; ?>" | php-7.0.8
To see where your mysql server has its socket, use this command:
cat /etc/mysql/my.cnf | grep socket
In my case, with Percona Mysql installed in my vagrant system the sock socket file happened to live here:
/var/run/mysqld/mysqld.sock
(notice that it is called mysqld not simply mysql)
I have several versions of php to choose from and these commands showed me which ones had issues and which ones were fine:
The answer for me was simply to include code in the vagrant provisioner script to create a symlink between /tmp/mysql.sock and /var/run/mysqld/mysqld.sock
if [ ! -L /tmp/mysql.sock ]; then
echo "Creating symbolic link for php 7 to connect to mysql.sock"
ln -s /var/run/mysqld/mysqld.sock /tmp/mysql.sock
fi
With the new symlink in place, the test script given before now works perfectly for all versions of PHP and I can use localhost in my code instead of having to give the 127.0.0.1 IP address.
add a comment |
I have several versions of PHP available to me via the shell - typing php and pressing tab shows which ones my autocomplete knows about.
For me, PHP 5.4, 5.5 and 5.6 were all working fine, but PHP 7 wasn't finding the mysql.sock, and was crashing with the "SQLSTATE[HY000] [2002] No such file or directory error" discussed in this question.
# Prints [ok]
echo "<?php print(new mysqli('localhost', 'root', 'root', 'mysql') ? '[ok]' : '[error]').PHP_EOL; ?>" | php-5.6.20
# Prints [error] and shows a warning
echo "<?php print(new mysqli('localhost', 'root', 'root', 'mysql') ? '[ok]' : '[error]').PHP_EOL; ?>" | php-7.0.8
To see where your mysql server has its socket, use this command:
cat /etc/mysql/my.cnf | grep socket
In my case, with Percona Mysql installed in my vagrant system the sock socket file happened to live here:
/var/run/mysqld/mysqld.sock
(notice that it is called mysqld not simply mysql)
I have several versions of php to choose from and these commands showed me which ones had issues and which ones were fine:
The answer for me was simply to include code in the vagrant provisioner script to create a symlink between /tmp/mysql.sock and /var/run/mysqld/mysqld.sock
if [ ! -L /tmp/mysql.sock ]; then
echo "Creating symbolic link for php 7 to connect to mysql.sock"
ln -s /var/run/mysqld/mysqld.sock /tmp/mysql.sock
fi
With the new symlink in place, the test script given before now works perfectly for all versions of PHP and I can use localhost in my code instead of having to give the 127.0.0.1 IP address.
I have several versions of PHP available to me via the shell - typing php and pressing tab shows which ones my autocomplete knows about.
For me, PHP 5.4, 5.5 and 5.6 were all working fine, but PHP 7 wasn't finding the mysql.sock, and was crashing with the "SQLSTATE[HY000] [2002] No such file or directory error" discussed in this question.
# Prints [ok]
echo "<?php print(new mysqli('localhost', 'root', 'root', 'mysql') ? '[ok]' : '[error]').PHP_EOL; ?>" | php-5.6.20
# Prints [error] and shows a warning
echo "<?php print(new mysqli('localhost', 'root', 'root', 'mysql') ? '[ok]' : '[error]').PHP_EOL; ?>" | php-7.0.8
To see where your mysql server has its socket, use this command:
cat /etc/mysql/my.cnf | grep socket
In my case, with Percona Mysql installed in my vagrant system the sock socket file happened to live here:
/var/run/mysqld/mysqld.sock
(notice that it is called mysqld not simply mysql)
I have several versions of php to choose from and these commands showed me which ones had issues and which ones were fine:
The answer for me was simply to include code in the vagrant provisioner script to create a symlink between /tmp/mysql.sock and /var/run/mysqld/mysqld.sock
if [ ! -L /tmp/mysql.sock ]; then
echo "Creating symbolic link for php 7 to connect to mysql.sock"
ln -s /var/run/mysqld/mysqld.sock /tmp/mysql.sock
fi
With the new symlink in place, the test script given before now works perfectly for all versions of PHP and I can use localhost in my code instead of having to give the 127.0.0.1 IP address.
answered Jan 11 '18 at 16:37
Martin FrancisMartin Francis
113
113
add a comment |
add a comment |
I get the same error "SQLSTATE[HY000] [2002] No such file or directory". And found that MySQL service was stopped. I started my MySQL service and its working fine.
add a comment |
I get the same error "SQLSTATE[HY000] [2002] No such file or directory". And found that MySQL service was stopped. I started my MySQL service and its working fine.
add a comment |
I get the same error "SQLSTATE[HY000] [2002] No such file or directory". And found that MySQL service was stopped. I started my MySQL service and its working fine.
I get the same error "SQLSTATE[HY000] [2002] No such file or directory". And found that MySQL service was stopped. I started my MySQL service and its working fine.
answered Jul 11 '18 at 8:52
PMBPMB
392220
392220
add a comment |
add a comment |
I had this same issue, and I used below to select which php have to use. /usr/local/etc/php/7.2/bin/php bin/magento setup:di:compile
See official docs:
SQLSTATE[HY000] [2002] No such file or directory
New contributor
add a comment |
I had this same issue, and I used below to select which php have to use. /usr/local/etc/php/7.2/bin/php bin/magento setup:di:compile
See official docs:
SQLSTATE[HY000] [2002] No such file or directory
New contributor
add a comment |
I had this same issue, and I used below to select which php have to use. /usr/local/etc/php/7.2/bin/php bin/magento setup:di:compile
See official docs:
SQLSTATE[HY000] [2002] No such file or directory
New contributor
I had this same issue, and I used below to select which php have to use. /usr/local/etc/php/7.2/bin/php bin/magento setup:di:compile
See official docs:
SQLSTATE[HY000] [2002] No such file or directory
New contributor
New contributor
answered 8 mins ago
Lee DertingLee Derting
1
1
New contributor
New contributor
add a comment |
add a comment |
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f51948%2fsqlstatehy000-2002-no-such-file-or-directory-error%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
I've fixed it by changing connection string, make sure that your mysql is on and you have all the tables exists in the database.
– Touqeer Shafi
Jun 5 '15 at 15:03