0

I have a mysql database that is meant to be used on a "demo" website. I need this to be restored or reset each hour.

I have have tried two methods to accomplish this and tried each method several ways (from what I read, either method should work as good as the other).

I am using a VPS on Dreamhost.

Here is what my CRON job looks like:

mysql -h my_db_host -u my_username -pmy_password my_db_name < /home/usr/scripts/simplecrud.sql

Error that I am getting each time the job runs is

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

How can I fix this ... what am I missing?

KulerGary
  • 217
  • 1
  • 4
  • 17
  • Possible duplicate of [Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)](https://stackoverflow.com/questions/4448467/cant-connect-to-local-mysql-server-through-socket-var-lib-mysql-mysql-sock) – TRiNE Sep 28 '17 at 16:11

1 Answers1

0

if the host is localhost, if yes try 127.0.0.1 instead

if this is also not working, try to check if the host from where you connect is allowed to connect (under the user)

cilap
  • 2,215
  • 1
  • 25
  • 51
  • I am not using localhost but the actual address – KulerGary Sep 28 '17 at 16:11
  • check if the given user has the permission to access from the given address – cilap Sep 28 '17 at 16:12
  • If you use phpmyadmin, you will see it under user management what hosts are allowed. Your host from which you connect has to be there for the user – cilap Sep 28 '17 at 16:27
  • User (me) has permission to access db (its my db and runs on my server ... the same server where the demo website). – KulerGary Sep 28 '17 at 16:34
  • so it is on localhost? if so try both -h 127.0.0.1 and -h localhost – cilap Sep 28 '17 at 16:38
  • No, not localhost ... my hosting provider explicitly states to not use "localhost" when connecting to your database but to use the hard address. – KulerGary Sep 28 '17 at 16:40
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/155535/discussion-between-cilap-and-kulergary). – cilap Sep 28 '17 at 16:45