LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-26-2011, 02:50 AM   #1
arvigeus
LQ Newbie
 
Registered: Mar 2011
Posts: 7

Rep: Reputation: 0
[Urgent] Cannot connect to MySQL database


(Sorry for the prefix but I'm applying for a job and need to complete a project by the next week)

Yesterday I installed MySQL, had some work with it, went to sleep. Today, trying to start it again gave me:
Code:
mysql -u root -p
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
Trying to run mysqld:
Code:
110826  9:42:55 [Warning] Can't create test file /var/lib/mysql/eee-1000H.lower-test
110826  9:42:55 [Warning] Can't create test file /var/lib/mysql/eee-1000H.lower-test
mysqld: Can't change dir to '/var/lib/mysql/' (Errcode: 13)
110826  9:42:55 [ERROR] Aborting

110826  9:42:55 [Note] mysqld: Shutdown complete
It starts as sudo, but still cannot connect

'ps ax | grep mysqld'
Code:
10001 pts/0    S+     0:00 grep mysqld
sudo cat /etc/hosts
Code:
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
Please, help!!!
 
Old 08-26-2011, 02:57 AM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,241

Rep: Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325
Looks like security SELinux http://www.linuxforums.org/forum/ser...ocation-2.html and/or ownerships/perms http://dev.mysql.com/doc/refman/5.5/...rmissions.html
 
Old 08-26-2011, 03:38 AM   #3
arvigeus
LQ Newbie
 
Registered: Mar 2011
Posts: 7

Original Poster
Rep: Reputation: 0
I'm using Lubuntu (no SELinux)
If it is permission issue, why can't start it with 'sudo mysql -u root -p'?
 
Old 08-26-2011, 03:58 AM   #4
arvigeus
LQ Newbie
 
Registered: Mar 2011
Posts: 7

Original Poster
Rep: Reputation: 0
(Sorry for double post)
Also, my /var/run/mysqld/mysqld.sock is missing
 
Old 08-26-2011, 05:59 AM   #5
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Slackware 10.1/10.2/12, Ubuntu 12.04, Crunchbang Statler
Posts: 3,786

Rep: Reputation: 282Reputation: 282Reputation: 282
mysqld.sock is missing because the daemon is not running.

Further, your sudo only applies to the mysql client, not to the mysql server.

The error message clearly indicates an permission error. I suggest that you check it. Below is my 'listing' for a more or less clean install on Ubuntu 10.04. It includes both permissions and ownership.

Code:
wim@ubuntu-desktop01:~$ sudo ls -ld /var/lib/mysql/
drwx------ 3 mysql mysql 4096 2011-08-26 11:50 /var/lib/mysql/
wim@ubuntu-desktop01:~$ sudo tree -pug /var/lib/mysql
/var/lib/mysql
|-- [-rw-r--r-- root     root    ]  debian-5.1.flag
|-- [-rw-rw---- mysql    mysql   ]  ibdata1
|-- [-rw-rw---- mysql    mysql   ]  ib_logfile0
|-- [-rw-rw---- mysql    mysql   ]  ib_logfile1
|-- [drwx------ mysql    root    ]  mysql
|   |-- [-rw-rw---- mysql    mysql   ]  columns_priv.frm
|   |-- [-rw-rw---- mysql    mysql   ]  columns_priv.MYD
|   |-- [-rw-rw---- mysql    mysql   ]  columns_priv.MYI
|   |-- [-rw-rw---- mysql    mysql   ]  db.frm
|   |-- [-rw-rw---- mysql    mysql   ]  db.MYD
|   |-- [-rw-rw---- mysql    mysql   ]  db.MYI
|   |-- [-rw-rw---- mysql    mysql   ]  event.frm
|   |-- [-rw-rw---- mysql    mysql   ]  event.MYD
|   |-- [-rw-rw---- mysql    mysql   ]  event.MYI
|   |-- [-rw-rw---- mysql    mysql   ]  func.frm
|   |-- [-rw-rw---- mysql    mysql   ]  func.MYD
|   |-- [-rw-rw---- mysql    mysql   ]  func.MYI
|   |-- [-rw-rw---- mysql    mysql   ]  general_log.CSM
|   |-- [-rw-rw---- mysql    mysql   ]  general_log.CSV
|   |-- [-rw-rw---- mysql    mysql   ]  general_log.frm
|   |-- [-rw-rw---- mysql    mysql   ]  help_category.frm
|   |-- [-rw-rw---- mysql    mysql   ]  help_category.MYD
|   |-- [-rw-rw---- mysql    mysql   ]  help_category.MYI
|   |-- [-rw-rw---- mysql    mysql   ]  help_keyword.frm
|   |-- [-rw-rw---- mysql    mysql   ]  help_keyword.MYD
|   |-- [-rw-rw---- mysql    mysql   ]  help_keyword.MYI
|   |-- [-rw-rw---- mysql    mysql   ]  help_relation.frm
|   |-- [-rw-rw---- mysql    mysql   ]  help_relation.MYD
|   |-- [-rw-rw---- mysql    mysql   ]  help_relation.MYI
|   |-- [-rw-rw---- mysql    mysql   ]  help_topic.frm
|   |-- [-rw-rw---- mysql    mysql   ]  help_topic.MYD
|   |-- [-rw-rw---- mysql    mysql   ]  help_topic.MYI
|   |-- [-rw-rw---- mysql    mysql   ]  host.frm
|   |-- [-rw-rw---- mysql    mysql   ]  host.MYD
|   |-- [-rw-rw---- mysql    mysql   ]  host.MYI
|   |-- [-rw-rw---- mysql    mysql   ]  ndb_binlog_index.frm
|   |-- [-rw-rw---- mysql    mysql   ]  ndb_binlog_index.MYD
|   |-- [-rw-rw---- mysql    mysql   ]  ndb_binlog_index.MYI
|   |-- [-rw-rw---- mysql    mysql   ]  plugin.frm
|   |-- [-rw-rw---- mysql    mysql   ]  plugin.MYD
|   |-- [-rw-rw---- mysql    mysql   ]  plugin.MYI
|   |-- [-rw-rw---- mysql    mysql   ]  proc.frm
|   |-- [-rw-rw---- mysql    mysql   ]  proc.MYD
|   |-- [-rw-rw---- mysql    mysql   ]  proc.MYI
|   |-- [-rw-rw---- mysql    mysql   ]  procs_priv.frm
|   |-- [-rw-rw---- mysql    mysql   ]  procs_priv.MYD
|   |-- [-rw-rw---- mysql    mysql   ]  procs_priv.MYI
|   |-- [-rw-rw---- mysql    mysql   ]  servers.frm
|   |-- [-rw-rw---- mysql    mysql   ]  servers.MYD
|   |-- [-rw-rw---- mysql    mysql   ]  servers.MYI
|   |-- [-rw-rw---- mysql    mysql   ]  slow_log.CSM
|   |-- [-rw-rw---- mysql    mysql   ]  slow_log.CSV
|   |-- [-rw-rw---- mysql    mysql   ]  slow_log.frm
|   |-- [-rw-rw---- mysql    mysql   ]  tables_priv.frm
|   |-- [-rw-rw---- mysql    mysql   ]  tables_priv.MYD
|   |-- [-rw-rw---- mysql    mysql   ]  tables_priv.MYI
|   |-- [-rw-rw---- mysql    mysql   ]  time_zone.frm
|   |-- [-rw-rw---- mysql    mysql   ]  time_zone_leap_second.frm
|   |-- [-rw-rw---- mysql    mysql   ]  time_zone_leap_second.MYD
|   |-- [-rw-rw---- mysql    mysql   ]  time_zone_leap_second.MYI
|   |-- [-rw-rw---- mysql    mysql   ]  time_zone.MYD
|   |-- [-rw-rw---- mysql    mysql   ]  time_zone.MYI
|   |-- [-rw-rw---- mysql    mysql   ]  time_zone_name.frm
|   |-- [-rw-rw---- mysql    mysql   ]  time_zone_name.MYD
|   |-- [-rw-rw---- mysql    mysql   ]  time_zone_name.MYI
|   |-- [-rw-rw---- mysql    mysql   ]  time_zone_transition.frm
|   |-- [-rw-rw---- mysql    mysql   ]  time_zone_transition.MYD
|   |-- [-rw-rw---- mysql    mysql   ]  time_zone_transition.MYI
|   |-- [-rw-rw---- mysql    mysql   ]  time_zone_transition_type.frm
|   |-- [-rw-rw---- mysql    mysql   ]  time_zone_transition_type.MYD
|   |-- [-rw-rw---- mysql    mysql   ]  time_zone_transition_type.MYI
|   |-- [-rw-rw---- mysql    mysql   ]  user.frm
|   |-- [-rw-rw---- mysql    mysql   ]  user.MYD
|   `-- [-rw-rw---- mysql    mysql   ]  user.MYI
|-- [-rw-rw---- root     root    ]  mysql_upgrade_info
`-- [-rw-rw---- mysql    mysql   ]  ubuntu-desktop01.pid
Hope this helps.

Last edited by Wim Sturkenboom; 08-26-2011 at 06:00 AM.
 
1 members found this post helpful.
Old 08-26-2011, 03:36 PM   #6
bentbrewer
LQ Newbie
 
Registered: May 2011
Location: In a brewery
Distribution: Ubuntu 11.04 & 10.04, CentOS 6, Fedora 15
Posts: 20

Rep: Reputation: Disabled
I had this problem once before and resetting the MySQL's root user's password fixed it. Caution - this is not the same as the system's root user so don't reset the su password. See the MySQL help page for this: http://dev.mysql.com/doc/refman/5.0/...rmissions.html
 
1 members found this post helpful.
Old 08-27-2011, 01:34 AM   #7
arvigeus
LQ Newbie
 
Registered: Mar 2011
Posts: 7

Original Poster
Rep: Reputation: 0
That's weird. I "solved" it. Don't ask me how, it's a mystery for me too. After some attempts I was able to produce another message, that my user has not enough rights to open the database. Funny thing is, that it does not apply for MySQL workbench program. So I entered from there and granted myself the needed permissions. Double weird.
I guess it's solved, purely on luck, but if it happens again I won't be able to fix it...
 
  


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
Trying to get PHP to connect to a MySQL Database bassplayer69 Programming 16 03-13-2008 10:27 PM
cannot connect to mysql database PAD_LOCK Programming 5 09-01-2006 03:03 PM
How To Connect To Posgresql/mysql Database Using C cs-mania Programming 4 07-06-2006 12:00 AM
cannot connect to mysql database from php rocordial Linux - Software 2 08-21-2005 03:05 PM
cannot connect to mysql database mrosati Linux - Software 19 07-15-2004 03:40 PM


All times are GMT -5. The time now is 12:43 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration