LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 01-24-2005, 06:32 AM   #1
welery
LQ Newbie
 
Registered: Jan 2005
Posts: 22

Rep: Reputation: 15
Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock


I'm getting the following error message:

Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock'

so I ran:

find / -name mysql.sock

and it doesn't show up, what should I do now? I'm using Mandrake 10.1 and this is the first time I'm using mysql. Should i try uninstalling mysql and reinstalling. I also noticed that there was an error file in

/var/lib/mysql

which had this in it:

50124 23:05:00 mysqld started
^G/usr/sbin/mysqld: Can't read dir of '/root/tmp/' (Errcode: 13)
InnoDB: The first specified data file ./ibdata1 did not exist:
InnoDB: a new database to be created!
050124 23:05:00 InnoDB: Setting file ./ibdata1 size to 10 MB
InnoDB: Database physically writes the file full: wait...
050124 23:05:01 InnoDB: Log file ./ib_logfile0 did not exist: new to be created
InnoDB: Setting log file ./ib_logfile0 size to 5 MB
InnoDB: Database physically writes the file full: wait...
050124 23:05:01 InnoDB: Log file ./ib_logfile1 did not exist: new to be created
InnoDB: Setting log file ./ib_logfile1 size to 5 MB
InnoDB: Database physically writes the file full: wait...
InnoDB: Doublewrite buffer not found: creating new
InnoDB: Doublewrite buffer created
InnoDB: Creating foreign key constraint system tables
InnoDB: Foreign key constraint system tables created
050124 23:05:02 InnoDB: Started
/usr/sbin/mysqld: ready for connections.
Version: '4.0.20' socket: '/var/lib/mysql/mysql.sock' port: 0
050124 23:05:02 /usr/sbin/mysqld: Normal shutdown

050124 23:05:02 InnoDB: Starting shutdown...
050124 23:05:04 InnoDB: Shutdown completed
050124 23:05:04 /usr/sbin/mysqld: Shutdown Complete

050124 23:05:04 mysqld ended
 
Old 01-24-2005, 06:48 AM   #2
deoren
Member
 
Registered: Oct 2003
Location: USA
Distribution: Ubuntu
Posts: 216

Rep: Reputation: 30
Lightbulb my.cnf

You can fix all of these problems through my.cnf, which is usually found at /etc/my.cnf

To get rid of those innodb errors (if you don't plan on using innodb), use this:

skip-innodb


If you don't plan on remote systems attaching directly to your database, and you're also running Apache on the system and want to interface the two, perhaps with a scripting language, enter this as well:

skip-networking

That will stop MySQL from running on anything but a socket (sockets are faster than tcp/ip access).

As for not finding the mysql.sock file,

Try:
Code:
find / | grep "sock"
and see what pops up.

Once you find it, you can enter the location here:

socket = /var/lib/mysql/mysql.sock

Just for a reference, here is my "my.cnf". It's a copy of my-medium.cnf (low memory in this system).

Quote:
# Example mysql config file for medium systems.
#
# This is for a system with little memory (32M - 64M) where MySQL plays
# a important part and systems up to 128M very MySQL is used together with
# other programs (like a web server)
#
# You can copy this file to
# /etc/my.cnf to set global options,
# mysql-data-dir/my.cnf to set server-specific options (in this
# installation this directory is /var/lib/mysql) or
# ~/.my.cnf to set user-specific options.
#
# One can in this file use all long options that the program supports.
# If you want to know which options a program support, run the program
# with --help option.

# The following options will be passed to all MySQL clients
[client]
#password = your_password
port = 3306
socket = /var/lib/mysql/mysql.sock

# Here follows entries for some specific programs

# The MySQL server
[mysqld]
port = 3306
socket = /var/lib/mysql/mysql.sock
skip-locking
skip-networking
skip-innodb

set-variable = key_buffer=16M
set-variable = max_allowed_packet=1M
set-variable = table_cache=64
set-variable = sort_buffer=512K
set-variable = net_buffer_length=8K
set-variable = myisam_sort_buffer_size=8M
server-id = 1

# Point the following paths to different dedicated disks
#tmpdir = /tmp/
#log-update = /path-to-dedicated-directory/hostname

# Uncomment the following if you are using BDB tables
#set-variable = bdb_cache_size=4M
#set-variable = bdb_max_lock=10000

# Uncomment the following if you are using InnoDB tables
#innodb_data_home_dir = /var/lib/mysql/
#innodb_data_file_path = ibdata1:10M:autoextend
#innodb_log_group_home_dir = /var/lib/mysql/
#innodb_log_arch_dir = /var/lib/mysql/
# You can set .._buffer_pool_size up to 50 - 80 %
# of RAM but beware of setting memory usage too high
#set-variable = innodb_buffer_pool_size=16M
#set-variable = innodb_additional_mem_pool_size=2M
# Set .._log_file_size to 25 % of buffer pool size
#set-variable = innodb_log_file_size=5M
#set-variable = innodb_log_buffer_size=8M
#innodb_flush_log_at_trx_commit=1
#set-variable = innodb_lock_wait_timeout=50

[mysqldump]
quick
set-variable = max_allowed_packet=16M

[mysql]
no-auto-rehash
# Remove the next comment character if you are not familiar with SQL
#safe-updates

[isamchk]
set-variable = key_buffer=20M
set-variable = sort_buffer=20M
set-variable = read_buffer=2M
set-variable = write_buffer=2M

[myisamchk]
set-variable = key_buffer=20M
set-variable = sort_buffer=20M
set-variable = read_buffer=2M
set-variable = write_buffer=2M

[mysqlhotcopy]
interactive-timeout
 
Old 01-24-2005, 06:51 AM   #3
welery
LQ Newbie
 
Registered: Jan 2005
Posts: 22

Original Poster
Rep: Reputation: 15
thanks. I think all it needed was a reboot
 
Old 01-24-2005, 06:51 AM   #4
deoren
Member
 
Registered: Oct 2003
Location: USA
Distribution: Ubuntu
Posts: 216

Rep: Reputation: 30
Quote:
Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock'
What are you using to get this error? The mysql commandline app or a script?
 
Old 01-24-2005, 10:23 AM   #5
deoren
Member
 
Registered: Oct 2003
Location: USA
Distribution: Ubuntu
Posts: 216

Rep: Reputation: 30
GNU/Linux != Windows

Quote:
Originally posted by welery
thanks. I think all it needed was a reboot
If that fixes it, I would say you have a strange situation indeed. Microsoft users have grown to accustomed to rebooting a Windows system to fix a problem, but rebooting should not fix yours.

If the problem is gone, then great, but it will probably surface again.

Those errors mentioned are innodb errors, and adding noinnodb to my.cnf will get rid of those.
 
Old 01-24-2005, 07:07 PM   #6
welery
LQ Newbie
 
Registered: Jan 2005
Posts: 22

Original Poster
Rep: Reputation: 15
I think the problem was that I jsut installed mysql and the actual process that it needs to run wasn't running. I wasn't exactly sure how to run it. I probably could have ran it with a command of some sort but when i rebooted it started the process again so mysql worked. I still also did add noinnodb to my.cnf and that removed the errors. but the original error Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' was cause because mysql process wasn't running
 
Old 07-10-2008, 03:58 PM   #7
pgedeon
LQ Newbie
 
Registered: Jul 2008
Posts: 2

Rep: Reputation: 0
Thumbs up

Quote:
Originally Posted by deoren View Post
If that fixes it, I would say you have a strange situation indeed. Microsoft users have grown to accustomed to rebooting a Windows system to fix a problem, but rebooting should not fix yours.

If the problem is gone, then great, but it will probably surface again.

Those errors mentioned are innodb errors, and adding noinnodb to my.cnf will get rid of those.
it worked for me thank you so much!!
 
Old 07-10-2008, 04:10 PM   #8
deoren
Member
 
Registered: Oct 2003
Location: USA
Distribution: Ubuntu
Posts: 216

Rep: Reputation: 30
Rebooting?
 
Old 07-11-2008, 02:06 PM   #9
pgedeon
LQ Newbie
 
Registered: Jul 2008
Posts: 2

Rep: Reputation: 0
Smile

Quote:
Originally Posted by deoren View Post
Rebooting?
thats just silly you cant fix a linux box by rebooting it lol.... i wish that was all i had to do!
i fixed my system by adding skip-networking skip-innodb to my.cnf
 
Old 08-15-2010, 06:03 AM   #10
makavelistein
LQ Newbie
 
Registered: Aug 2010
Posts: 2

Rep: Reputation: 0
Why rebooting may work?

Yes we all know rebooting is nooby. However I think it may sort out some problems, such as restarting apache... etc


All I can say is that if restarting is your solution for your linux server you will have learned nothing of why the error had been occuring in the first place.

May as well be using XAMPP on your XP box :P
 
Old 11-26-2010, 10:31 AM   #11
elaich
LQ Newbie
 
Registered: Apr 2010
Location: Salé
Distribution: Opensuse, Fedora, ..
Posts: 9

Rep: Reputation: 0
I'm getting the same error, is there any service that i need to start so i can connect to mysql ?
 
Old 11-26-2010, 06:57 PM   #12
yancek
LQ Guru
 
Registered: Apr 2008
Distribution: Slackware, Ubuntu, PCLinux,
Posts: 10,517

Rep: Reputation: 2493Reputation: 2493Reputation: 2493Reputation: 2493Reputation: 2493Reputation: 2493Reputation: 2493Reputation: 2493Reputation: 2493Reputation: 2493Reputation: 2493
You need to start the mysqld daemon, varies depending upon your distribution. To see if mysql is running, open a terminal and type: ps -e | grep my; if it is not post back with distribution you are using.
 
Old 09-13-2011, 11:20 AM   #13
The Hound
LQ Newbie
 
Registered: Sep 2011
Location: Texas
Distribution: Debian, Ubuntu, Fedora
Posts: 3

Rep: Reputation: Disabled
Need to install mysql-server

I had the same problem after a fresh install of mysql. I fixed it by installing mysql-server, then running /etc/init.d/mysqld start. That worked for me.

Last edited by The Hound; 09-13-2011 at 11:21 AM. Reason: spelling error
 
Old 09-29-2011, 10:22 AM   #14
ElvinKnight
LQ Newbie
 
Registered: Sep 2011
Posts: 1

Rep: Reputation: Disabled
Cool

Quote:
Originally Posted by The Hound View Post
I had the same problem after a fresh install of mysql. I fixed it by installing mysql-server, then running /etc/init.d/mysqld start. That worked for me.
I had this error too after fresh install in CentOS. The above suggestion fixed it for me. Thanks Hound. Also Thanks Linux Questions! First and only stop for fixing this one... I Be Back! 8^D
 
Old 10-14-2011, 03:30 PM   #15
allenhighnote
LQ Newbie
 
Registered: Oct 2011
Posts: 1

Rep: Reputation: Disabled
my solution

I had this same problem on a Ubuntu 11 virtual machine running on vmware server 2.0. It turned out that I had broken my /etc/network/interfaces file. Once I got the loopback portion of the file corrected, MySQL came back fine.

For me, it was making sure that the following lines were in the /etc/network/interfaces file:

auto lo
iface lo inet loopback

When you connect to MySQL via the local machine using # mysql -uusername -ppassword it tries to connect to 127.0.0.1 (local loopback) However, if you’ve botched your interfaces file as I had, your mysql gets screwed. I tried uninstalling everything mysql but that didn’t work. I even made sure that I went through the entire filesystem and deleted every file and directory with “mysql” in it’s name and then reinstalling. No luck. But when I got my interfaces file corrected, everything was fine.

see # man interfaces for a little help on the file.
 
1 members found this post helpful.
  


Reply



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
ERROR 2002: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql. NoviceW Linux - Networking 17 09-17-2014 02:13 PM
ERROR 2002: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql. suziecorbett Linux - Software 8 10-09-2008 01:52 AM
Problems with MySQL on SuSE: Can't Connect (/var/lib/mysql/mysql.sock) neocookie Linux - Software 8 02-07-2008 11:48 PM
Buzilla issue: "Can't connect to local MySQL server through socket '/tmp/mysql.sock'" vitopn Linux - General 3 05-21-2007 10:13 AM
mysql error Can't connect to local MySQL server through socket '/var/lib/mysql/mysql. Dannux Linux - Software 3 03-24-2006 08:44 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 08:49 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration