I am using Megento 2.1.8 and Php version php 7.0.20 on Mac with MAMP I am getting error when re-indexing:
SQLSTATE[HY000] [2002] No such file or directory. people resolved issue by setting the database hostname as 127.0.0.1 instead of localhost .
Question is: how can I set the database hostname as 127.0.0.1 instead of localhost?
Go to phpmyadmin->opendatabase->open coreconfigdata -> change securebaseurl and insecure base url->use instead of localhost to 127.0.0.1
Try updating the file /app/etc/env.php under your magento installation directory, you can change the database host there
Related
I need your help to resolve the below issue.
I have installed XAMPP server on a virtual machine having Windows 10. I changed the ports from 80 to 8080 and MySQL from 3306 to 3307. Still, I am getting an error when I try to access phpMyAdmin using localhost
Did you also change the phpmyadmin configuration to use the new port?
If not do it with the following steps:
Open the xampp controlpanel
click config behind apache -> then click phpMyAdmin
search for the line $cfg['Servers'][$i]['host'] = '127.0.0.1'; and add $cfg['Servers'][$i]['port'] = 'your new port number'; under it
save the file
I have servers :
a Sql server
a VPS
I installed apache on my debian server.
I want to access my SQL server through PDO.
But an error occurs :
SQLSTATE[HY000] [2003] Can't connect to MySQL server on 'my_sql_server_ip' (110)'
However, I can access my SQL server from local apache server (MAMP).
So I think the problem is client side.
Any suggestion ?
On MAMP , click File Menu > Edit Template > MySQL my.cnf
and change bind-address = 127.0.0.1 by bind-address = 0.0.0.0
(don't edit directly /Applications/MAMP/tmp/mysql/my.cnf because MAMP will overwrite the file on restart)
On Mac OS X 10.6, I am able to connect to mysql in php with
$mysql = mysql_connect(localhost,user,password)
However, if I use the same in Mac OS X 10.9 (Mavericks), I get the error message:
Warning: mysql_connect(): No such file or directory
if I use $mysql = mysql_connect("127.0.0.1",user,password), it works OK, but I'd rather not make the change everywhere.
I've read on this site that there is a socket issue, but I already have this in php.ini.default: pdo_mysql.default_socket=/tmp/mysql.sock
Any idea on how to make mysql_connect(localhost,user,password) work on 10.9 ?
Please read those articles:
http://www.coolestguidesontheplanet.com/downtown/get-apache-mysql-php-and-phpmyadmin-working-osx-109-mavericks
AllowOverride for .htaccess on local machine giving 403 Forbidden
http://coolestguidesontheplanet.com/how-to-install-mcrypt-for-php-on-mac-osx-lion-10-7-development-server/
http://michaelgracie.com/2013/10/29/plugging-mcrypt-into-php-on-mac-os-x-mavericks-10-9/
what you need is to edit the hostnames file, but I am a PC user, so I can't walk you with that on mac. Anyway here is what I found and I suppose it is the same as your OS version
Step 1 – Open the Terminal.app
Either by start typing Terminal on the Spotlight, or by going into
Applications -> Utilities -> Terminal.
Step 2 – Open the hosts file
Open the hosts by typing on the Terminal that you have just opened:
1$ sudo nano /private/etc/hosts Type your user password when
prompted.
Step 3 – Edit the hosts file
The hosts file contains some comments (lines starting with the #
symbol), as well as some default hostname mappings (e.g. 127.0.0.1 –
localhost).
source: http://decoding.wordpress.com/2009/04/06/how-to-edit-the-hosts-file-in-mac-os-x-leopard/
what you need is to write an entry for 127.0.0.1 - localhost
if it is not already there.
If you call mysql_connect() with localhost as a first argument PHP tries to connect using a UNIX domain socket instead of TCP.
Probably it looks for wrong socket name and/or you mysql only listens on TCP.
You should check your mysql settings (/etc/mysql ? search for socket) and the php mysql.default_socket config variable. (The pdo_mysql.default_socket you mentions is used when you connect using pdo.)
For example on my debian:
$ grep socket /etc/mysql/my.cnf
socket = /var/run/mysqld/mysqld.sock
(Otherwise your life would be easier if you use any kind of db abstraction layer, and storing the connection details only once.)
I'm trying to install an opensource software on my local and I'm running zendserver on linux ubuntu.
I created the database and provided a correct user and password.
But as soon as I click on submit button I get a MySQL 2002 error saying:
(2002) No such file or directory
I tried to restart apache2 but still I get the same error after I have restarted apache2.
How can I resolve this Mysql error?
You don't have permissions to access the directory /var/lib/mysql/whatever.sock because mysql is the owner of the folder
or
/path/whatever.sock doesn't exist.
You can try this though [Linux specific, but what other operating systems are there?]
Go to /etc/my.cnf and change/add the lines:
[mysqld]
datadir=/var/lib/mysql
socket=/tmp/mysql.sock
[client]
socket=/tmp/mysql.sock
This way the client and server use the same socket and it's in a public directory.
My code was working all fine yesterday and today it suddenly just don't want to connect to my database. I have changed no settings on it or on the code and I haven't updated any software either. All I do is this:
new PDO('mysql:host=localhost;port=3306;dbname=test', 'username', 'password');
And I get a nice exception message saying this:
Warning: PDO::__construct(): [2002] No such file or directory (trying to connect via unix:///tmp/mysql.sock) in ...
The thing is: I'm clearly not trying to connect using a unix socket but using TCP/IP. What am I doing wrong? Is there something I'm missing here?
Thanks for any help.
You are using a Unix socket. When reading "localhost" MySQL client libraries don't interpret it as TCP host "localhost" and resolve that name but use the default Socket location. For using TCP on the local machine you have to use 127.0.0.1 as hostname.
To specify the past use unix_socketinstead of host in the DSN. The location of the socket used for localhost can be defined at compile time or in some versions of PHP using pdo_mysql.default_socket in the php.ini.
From the PHP documentation about connection to MySQL using PDO: PDO_MYSQL DNS
The note at the very end says:
Unix only:
When the host name is set to "localhost", then the connection to the
server is made thru a domain socket. If PDO_MYSQL is compiled against
libmysql then the location of the socket file is at libmysql's
compiled in location. If PDO_MYSQL is compiled against mysqlnd a
default socket can be set thru the pdo_mysql.default_socket setting.
So in order to fix this you would have to properly configure in php.ini the location of your mysql.sock
Find your mysql.sock file. Common locations:
/tmp/mysql.sock
/tmp/mysql/mysql.sock
/var/mysql/mysql.sock
or if you use MAMP or LAMP look for inside the tmp folder for mysql
Edit your php.ini file and properly set the value for pdo_mysql.default_socket
Restart your Apache server to pickup the changes in the php.ini file
On Ubuntu, you can use this setting in php.ini
pdo_mysql.default_socket=/var/run/mysqld/mysqld.sock
There's an update to the docs for Drush which is documented here.
I just added this line:
'unix_socket' => '/Applications/XAMPP/xamppfiles/var/mysql/mysql.sock',
and all was well.