LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock (https://www.linuxquestions.org/questions/linux-software-2/cant-connect-to-local-mysql-server-through-socket-var-lib-mysql-mysql-sock-281557/)

welery 01-24-2005 06:32 AM

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

deoren 01-24-2005 06:48 AM

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

welery 01-24-2005 06:51 AM

thanks. I think all it needed was a reboot

deoren 01-24-2005 06:51 AM

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?

deoren 01-24-2005 10:23 AM

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.

welery 01-24-2005 07:07 PM

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

pgedeon 07-10-2008 03:58 PM

Quote:

Originally Posted by deoren (Post 1427309)
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!!

deoren 07-10-2008 04:10 PM

Rebooting? :confused:

pgedeon 07-11-2008 02:06 PM

Quote:

Originally Posted by deoren (Post 3210472)
Rebooting? :confused:

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

makavelistein 08-15-2010 06:03 AM

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

elaich 11-26-2010 10:31 AM

I'm getting the same error, is there any service that i need to start so i can connect to mysql ?

yancek 11-26-2010 06:57 PM

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.

The Hound 09-13-2011 11:20 AM

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.

ElvinKnight 09-29-2011 10:22 AM

Quote:

Originally Posted by The Hound (Post 4470702)
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

allenhighnote 10-14-2011 03:30 PM

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.


All times are GMT -5. The time now is 01:37 AM.