“mysqldump: Got error: 2002: Can’t connect to local MySQL server through socket ‘/var/run/mysql/mysql.sock’ (2) when trying to connect” (Updated) (Updated Again–Fixed) 2
When entering the command
mysqldump -u [username] -p[password] –opt [databasename]
Man, I hate trouble-shooting SQL.
Now, I know more about SQL than most computer users. A good part of my work at Checkpoint involved supporting SQL databases, both in Crystal Reports and in M$SQL (I preferred Crystal). MySQL is not all that different. Structured Query Language is, after all Structured Query Language.
But what I know how to do is change the oil and check the fluid levels. Fuel injection is a mystery to me. So are the inner workings of SQL.
When I have fuel injection problems, I take my vehicle to Jack Smith’s; I know Donnie will get it right the first time and fix the problem.
I got no Jack Smith’s for SQL.
When I have to shoot this kind of trouble, it’s like reading a Proust novel in French using a French-English/English-French dictionary.
Oh, well. I’ll figure it out. I always do.
And when I do, I’ll write a script (it’s actually half-written) that makes a folder over there
—–>,
on my second hard drive, named with today’s date (year-month-date-hour-minute) and backs my database up to it. Then I’ll make the script a cron job so it runs every night.
No more three months of lost blogging for me.
(I know that Opie is the only regular I have who’s going to have any idea what the heck I’m talking about. That’s why all the links. We were all newbies once.)
Click to read the updates.
Addendum, The Next Day:
I’m making progress. With the help of this forum post, I found that my mysql socket (the imaginary place where mysqldump would connect with msqld) is
/opt/lampp/var/mysql/mysql.sock
whereas mysqldump is looking for it at
/var/run/mysql/mysql.sock
In other words, it’s knocking on the wrong damned door.
Next: Finding out how to tell it to knock on the right damn door.
That has to wait, though. It’s time to get ready to drink liberally.
I also think I figured out why my other cron job wasn’t working. One too many asterisks.
Addendum, Wednesday 10/22/2008:
With the help of this webpage, I learned how to pass the socket to mysqldump. This command worked and produced an *.sql backup file named “wind.sql.”
mysqldump -S /opt/lampp/var/mysql/mysql.sock -u [username] -p[password] [databasename] > [filename].sql
Note that this command is entered on one line: The wrap is forced by this format.
Here’s how the command parses:
mysqldump, connect to mysqld by knocking on this door:
mysqldump -S /opt/lampp/var/mysql/mysql.sock
I, [Username] am telling you to do that. Here’s my password:
-u [username] -p[password]
I want you to dump the database named [databasename] into an *.sql file named [filename].sql
[databasename] > [filename].sql
I just tested my script and it works. Now to make it cron job so my database gets backed up automatically.
Oh, yeah. I was correct about the cron job I mentioned at the end of yesterday’s update. Too many asterisks.
October 20, 2008 at 4:46 pm
Hey! I know something even better. Stay away from it!!! Actually, since I don’t think I would have to use anything like that, I don’t worry about it. Yes, I did look. Excel works for our little operation.
October 20, 2008 at 5:48 pm
Actually, your blog runs on MySQL. And Perl, php, and Apache.
You just don’t see it because you have a Jack Smith for MySQL. Your Jack Smith is called “WordPress dot com.”