Jump to content

Link to database cannot be established: SQLSTATE[HY000] [2002]


Recommended Posts

I installed PrestaShop (Version 1.6.0.11) using "Softaculous" from my hosting company, everything went fine while installing but got error when accessing my site. I am getting error as below when I access my site http://mck.x10.mx/prestashop/

Link to database cannot be established: SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

My config/settings.inc.php has following settings (actual values changed)

define('_DB_SERVER_', 'localhost');
define('_DB_NAME_', 'mydbname');
define('_DB_USER_', 'mydbuser');
define('_DB_PASSWD_', 'mydbpassword');
define('_DB_PREFIX_', 'ps_');
define('_MYSQL_ENGINE_', 'InnoDB');

NOTE: I also have wordpress site and it is working with similar credentials, so I know the database is working.

 

The wordpress site settings are

/** The name of the database for WordPress */
define('DB_NAME', 'mydbname');

/** MySQL database username */
define('DB_USER', 'mydbuser');

/** MySQL database password */
define('DB_PASSWORD', 'mydbpassword');

/** MySQL hostname */
define('DB_HOST', 'localhost');

/** Database Charset to use in creating database tables. */
define('DB_CHARSET', 'utf8');

/** The Database Collate type. Don't change this if in doubt. */
define('DB_COLLATE', '');

/**
 * WordPress Database Table prefix.
 *
 * You can have multiple installations in one database if you give each a unique
 * prefix. Only numbers, letters, and underscores please!
 */
$table_prefix  = 'wp_';


Edited by mckm (see edit history)
Link to comment
Share on other sites

I think the socket should be at /var/run/mysqld/mysqld.sock, not /tmp/mysql.sock.

What do I need to change? Where do I change it?

 

and I do not think it will work if it is using raw sockets or something since my Hosting company may not allow it.

Edited by mckm (see edit history)
Link to comment
Share on other sites

Finally I solved it myself.

 

1) Deleted the file in <prestashopdir>/config/settings.inc.php

2) Downloaded prestashop_1.6.0.11.zip

3) Unzippped the doenloadef zip file on my local system

4) Zipped up all the folder install/* into install.zip file (making sure the zip file contained the install directory itself in the root)

5) FTP the install.zip file to my web server to <prestashopdir> and unzipped the zip file which created the install directory.

6) Launched the install app from my server using http://mck.x10.mx/prestashop/install

7) followed the steps till Database configuration menu.

8) Filled in all the db server parameters and set Database Server=127.0.0.1 (instead of "localhost")

9) Test connection : SUCCESS

10) Continued with database table created trough the install app.

11) deleted the install folder as displayed.

Edited by mckm (see edit history)
Link to comment
Share on other sites

  • 1 year later...
  • 9 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...