LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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, 01:50 AM   #1
arvigeus
LQ Newbie
 
Registered: Mar 2011
Posts: 12

Rep: Reputation: 1
[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, 01:57 AM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,352

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
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, 02:38 AM   #3
arvigeus
LQ Newbie
 
Registered: Mar 2011
Posts: 12

Original Poster
Rep: Reputation: 1
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, 02:58 AM   #4
arvigeus
LQ Newbie
 
Registered: Mar 2011
Posts: 12

Original Poster
Rep: Reputation: 1
(Sorry for double post)
Also, my /var/run/mysqld/mysqld.sock is missing
 
Old 08-26-2011, 04:59 AM   #5
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Ubuntu 12.04, Antix19.3
Posts: 3,794

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 05:00 AM.
 
1 members found this post helpful.
Old 08-26-2011, 02:36 PM   #6
bentbrewer
LQ Newbie
 
Registered: May 2011
Location: In a brewery
Distribution: Ubuntu 18.04, RHEL
Posts: 21

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, 12:34 AM   #7
arvigeus
LQ Newbie
 
Registered: Mar 2011
Posts: 12

Original Poster
Rep: Reputation: 1
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 09:27 PM
cannot connect to mysql database PAD_LOCK Programming 5 09-01-2006 02:03 PM
How To Connect To Posgresql/mysql Database Using C cs-mania Programming 4 07-05-2006 11:00 PM
cannot connect to mysql database from php rocordial Linux - Software 2 08-21-2005 02:05 PM
cannot connect to mysql database mrosati Linux - Software 19 07-15-2004 02:40 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:44 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
Open Source Consulting | Domain Registration