LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
Search this Thread
Old 01-16-2007, 10:42 AM   #1
radiodee1
Member
 
Registered: Oct 2006
Location: New York
Distribution: Debian
Posts: 673
Blog Entries: 11

Rep: Reputation: 36
mysql needs mysqld.sock?


I have Debian etch and apache2 and php and mysql. Somehow I messed up mysql. It won't start at boot time. When I type

Code:
#/etc/init.d/mysql start
it says there's no socket at "/var/run/mysqld/mysqld.sock". Is there a way to just create this socket, and is this my problem, or just a symptom? I tried "apt-get remove mysql-server" and then "apt-get install mysql-server" but it didn't make the socket on its own. Any help would be greatly greatly apreciated. Thanks in advance...
 
Old 01-17-2007, 04:07 AM   #2
bathory
Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 10,925

Rep: Reputation: 1327Reputation: 1327Reputation: 1327Reputation: 1327Reputation: 1327Reputation: 1327Reputation: 1327Reputation: 1327Reputation: 1327Reputation: 1327
Check if the dir /var/run/mysqld exists and is writable by mysql:
Code:
ls -la /var/run/mysqld
Also you can edit my.cnf (/etc/mysql/my.cnf) and change the location of the socket to another dir, for example:
Code:
socket          = /tmp/mysql.sock
either in the [client] and the [mysqld] section.

Regards
 
Old 01-18-2007, 01:29 PM   #3
radiodee1
Member
 
Registered: Oct 2006
Location: New York
Distribution: Debian
Posts: 673
Blog Entries: 11

Original Poster
Rep: Reputation: 36
I tried setting the permissions on the "/var/run/mysqld" folder. It didn't help. Then I was off to change the location of the socket in the my.cnf file.

I changed the two places it asked for the location of the socket, at [client] and [mysqld], from "/var/run/mysqld/mysqld.sock" to "/tmp/mysqld.sock". No dice. mysql still doesn't work.

I have a question. In the my.cnf file, in the [client] section, it says you should change the debian.cnf file if you change the socket location but the debian.cnf file says not to change the contents (of the debian.cnf file) by hand. It says

Quote:
# Automatically generated for Debain scripts. DO NOT TOUCH.
Do I touch it anyway? Is there a tool for changing this file? Can I proceed without changing it? Will it help with my problem? When I type "/etc/init.d/mysql start" (as above) I get the following error.

Quote:
/usr/bin/mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)'
Check that mysqld is running and that the socket: '/var/run/mysqld/mysqld.sock' exists!
I'm guessing I need to change that debian.cnf file, or there is another place where that socket location is specified. I dont know. Any help would be apreciated.

Last edited by radiodee1; 01-18-2007 at 02:05 PM.
 
Old 01-19-2007, 02:18 AM   #4
bathory
Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 10,925

Rep: Reputation: 1327Reputation: 1327Reputation: 1327Reputation: 1327Reputation: 1327Reputation: 1327Reputation: 1327Reputation: 1327Reputation: 1327Reputation: 1327
Quote:
Do I touch it anyway? Is there a tool for changing this file? Can I proceed without changing it? Will it help with my problem?
If the location of mysql.sock is also written in that file you can try to edit it (make a backup first, just in case something goes wrong) and see what happens. If that doesn't work check this to see if it solves your problem.

Regards
 
Old 01-19-2007, 11:11 AM   #5
radiodee1
Member
 
Registered: Oct 2006
Location: New York
Distribution: Debian
Posts: 673
Blog Entries: 11

Original Poster
Rep: Reputation: 36
I tried changing the debian.cnf file with no good results. I checked out the link you provided (good link, bye the way) and I changed the locations of the mysqld.pid file, but no good results. The error message when I type "/etc/init.d/mysql start" now mentions "/tmp/mysqld.sock" instead of "/var/run/mysqld/mysqld.sock", but nothing else changed.

I was looking at the standard php info page ("phpinfo();" in a php document served by apache2), and there's a section for mysql, even though mysql isn't running. I went to "/etc/php4/apache2/php.ini" and went to the mysql section and specified the location for "mysqld.sock". Then the php info page lists, in two different places, both the old location and the new location for "mysqld.sock".

Where it should show MYSQL_SOCKET under "MySQL support" it shows the old location. Where it should show mysql.default_socket under "directive" it shows the new location. Is there another configuration file somewhere that I'm totally missing?

EDIT: I only noticed now that if I type "/etc/init.d/mysql start" as root, I get an error message that mentions "/tmp/mysqld.sock". If I type "/etc/init.d/mysql start" as normal user, I get an error message that mentions "/var/run/mysqld/mysqld.sock".

I know this is kind of dense and maybe hard to figure out, but I really apreciate the help. Thanks.

Last edited by radiodee1; 01-19-2007 at 12:27 PM.
 
Old 01-20-2007, 08:32 AM   #6
bathory
Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 10,925

Rep: Reputation: 1327Reputation: 1327Reputation: 1327Reputation: 1327Reputation: 1327Reputation: 1327Reputation: 1327Reputation: 1327Reputation: 1327Reputation: 1327
You can try to start mysqld either using the mysqld_safe script if your distro uses it (it's available if you install the binary or source from mysql site), or directly using myslqd and see what happens:
Code:
/path/to/mysqld_safe --user=mysql &
or
/path/to/mysqld --user=mysql --socket=/tmp/mysql.sock --(other options)
Of course you have to change the location of the socket to be the same in all the relevant files.
Another thing to check is, if you have enabled your loopback interface (lo):
Code:
ifconfig -a
Regards
 
Old 01-20-2007, 10:20 AM   #7
radiodee1
Member
 
Registered: Oct 2006
Location: New York
Distribution: Debian
Posts: 673
Blog Entries: 11

Original Poster
Rep: Reputation: 36
Well here's what happened when I tried "mysqld". Is this helpfull?

Quote:
:/usr/sbin# ./mysqld --user=mysql --socket=/tmp/mysql.sock
070120 11:11:06 InnoDB: Started
070120 11:11:06 ./mysqld: Can't open file: 'host.MYI'. (errno: 142)
070120 11:11:06 Fatal error: Can't open privilege tables: File '/usr/share/mysql/charsets/?.conf' not found (Errcode: 2)
070120 11:11:06 Aborting

070120 11:11:06 InnoDB: Starting shutdown...
070120 11:11:08 InnoDB: Shutdown completed
070120 11:11:08 ./mysqld: Shutdown Complete
"ifconfig -a" seems to return what it should.

Quote:
...
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:11194 errors:0 dropped:0 overruns:0 frame:0
TX packets:11194 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:775013 (756.8 KiB) TX bytes:775013 (756.8 KiB)
...
Is this helpfull? Also, if I reset the mysql.sock to some new location, what permissions should that new location have?
 
Old 01-20-2007, 05:16 PM   #8
bathory
Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 10,925

Rep: Reputation: 1327Reputation: 1327Reputation: 1327Reputation: 1327Reputation: 1327Reputation: 1327Reputation: 1327Reputation: 1327Reputation: 1327Reputation: 1327
Quote:
070120 11:11:06 ./mysqld: Can't open file: 'host.MYI'. (errno: 142)
070120 11:11:06 Fatal error: Can't open privilege tables: File '/usr/share/mysql/charsets/?.conf' not found (Errcode: 2)
According to the errors above it seems that after mysql installation you didn't run the "mysql_install_db" script which is used to create the initial mysql database, grant privileges etc. I don't know how you installed mysql, but this must be done before anything else. You can read the postinstallation tasks here. Mind that the location of these files may vary according to your installation method.
 
Old 01-21-2007, 07:11 AM   #9
radiodee1
Member
 
Registered: Oct 2006
Location: New York
Distribution: Debian
Posts: 673
Blog Entries: 11

Original Poster
Rep: Reputation: 36
Still trouble. Thanks for all your help. I've still got problems. I read the link. I think it was helpfull. I tried the program mysql_install_db. I followed the link. First I erased the folder /var/lib/mysql/mysql so that I could create a new one. Then I typed mysql_install_db as root. I checked and the file had been recreated. Then I typed "mysql_install_db --user=mysql" to initialize the tables. It seemed to go well.

When I try "mysql start" I get the following

Quote:
dcl:/etc# /etc/init.d/mysql start
Starting MySQL database server: mysqld...failed.
Please take a look at the syslog.
/usr/bin/mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)'
Check that mysqld is running and that the socket: '/tmp/mysql.sock' exists!
When I try "mysqld_safe" I get the following

Quote:
dcl:/etc# mysqld_safe --user=mysql
Starting mysqld daemon with databases from /var/lib/mysql
mysqld_safe[5512]: started
STOPPING server from pid file /tmp/mysqld.pid
mysqld_safe[5518]: ended
when I try "mysqld" I get the following

Quote:
dave@dcl:/etc$ /usr/sbin/mysqld --user=mysql --socket=/tmp/mysql.sock
070121 8:04:18 Can't start server: Bind on TCP/IP port: Address already in use
070121 8:04:18 Do you already have another mysqld server running on port: 3306 ?
070121 8:04:18 Aborting

070121 8:04:18 /usr/sbin/mysqld: Shutdown Complete
That's everything. Any help would be apreciated. Thanks for all your time so far. I think my mysql database directory was messed up, and the command "mysql_install_db" helped. The socket problem seems to remain, but the error messages seem to have changed. When I read "Do you already have another mysqld server running on port: 3306 ?" I wondered, so I tried phpmyadmin again but no dice.
 
Old 01-22-2007, 02:12 AM   #10
bathory
Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 10,925

Rep: Reputation: 1327Reputation: 1327Reputation: 1327Reputation: 1327Reputation: 1327Reputation: 1327Reputation: 1327Reputation: 1327Reputation: 1327Reputation: 1327
Quote:
070121 8:04:18 Can't start server: Bind on TCP/IP port: Address already in use
070121 8:04:18 Do you already have another mysqld server running on port: 3306 ?
This means that there is already a mysqld runnig. You can check syslog as suggested by the startup script and also the other log files, specially mysql ones to see if you find out what happens. You can kill the process and try again. Or this is due to the fact that you ran this command (dave@dcl:/etc$ /usr/sbin/mysqld --user=mysql --socket=/tmp/mysql.sock) without being root (note the $ at the prompt)
Quote:
I typed mysql_install_db as root. I checked and the file had been recreated. Then I typed "mysql_install_db --user=mysql" to initialize the tables. It seemed to go well.
From my experience with mysql this command is a little tricky. I run it without the "--user=mysql" and then manually change ownership of the datadir. Assuming that yours is /var/lib/mysql/mysql, run:
Code:
chown -R mysql:mysql /var/lib/mysql/mysql
If you think you have messed up your mysql installation, you can uninstall it and install it again using either your distro's package manager, or the binary from www.mysql.com
 
Old 01-25-2007, 05:33 AM   #11
radiodee1
Member
 
Registered: Oct 2006
Location: New York
Distribution: Debian
Posts: 673
Blog Entries: 11

Original Poster
Rep: Reputation: 36
Thanks for your help. I reinstalled, and this time I made sure to remove everything related to mysql. I removed or changed all the configuration files, and now mysql works great. Thanks again.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock welery Linux - Software 19 03-06-2014 07:19 AM
Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) cygnus-x1 Linux - Software 2 06-05-2008 01:14 PM
Problems with MySQL on SuSE: Can't Connect (/var/lib/mysql/mysql.sock) neocookie Linux - Software 8 02-07-2008 11:48 PM
Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) sunlinux Linux - Software 1 11-07-2006 12:08 AM
Mysql Installation on Gentoo - mysqld.sock? Bob Gaskin Linux - Software 1 12-04-2003 11:27 PM


All times are GMT -5. The time now is 05:17 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration