Linux - Server This forum is for the discussion of Linux Software used in a server related context. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
01-16-2007, 10:42 AM
|
#1
|
Member
Registered: Oct 2006
Location: New York
Distribution: Debian
Posts: 675
Rep:
|
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...
|
|
|
01-17-2007, 04:07 AM
|
#2
|
LQ Guru
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,223
|
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
|
|
|
01-18-2007, 01:29 PM
|
#3
|
Member
Registered: Oct 2006
Location: New York
Distribution: Debian
Posts: 675
Original Poster
Rep:
|
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.
|
|
|
01-19-2007, 02:18 AM
|
#4
|
LQ Guru
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,223
|
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
|
|
|
01-19-2007, 11:11 AM
|
#5
|
Member
Registered: Oct 2006
Location: New York
Distribution: Debian
Posts: 675
Original Poster
Rep:
|
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.
|
|
|
01-20-2007, 08:32 AM
|
#6
|
LQ Guru
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,223
|
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):
Regards
|
|
|
01-20-2007, 10:20 AM
|
#7
|
Member
Registered: Oct 2006
Location: New York
Distribution: Debian
Posts: 675
Original Poster
Rep:
|
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?
|
|
|
01-20-2007, 05:16 PM
|
#8
|
LQ Guru
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,223
|
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.
|
|
|
01-21-2007, 07:11 AM
|
#9
|
Member
Registered: Oct 2006
Location: New York
Distribution: Debian
Posts: 675
Original Poster
Rep:
|
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.
|
|
|
01-22-2007, 02:12 AM
|
#10
|
LQ Guru
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,223
|
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
|
|
|
01-25-2007, 05:33 AM
|
#11
|
Member
Registered: Oct 2006
Location: New York
Distribution: Debian
Posts: 675
Original Poster
Rep:
|
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. 
|
|
|
All times are GMT -5. The time now is 12:36 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|