LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 04-23-2014, 09:38 AM   #1
jojanmpaul
Member
 
Registered: Sep 2012
Location: Bangalore
Posts: 80

Rep: Reputation: Disabled
mysql -u root -p fails to connect


Hello,

/etc/init.d/mysql restart
Shutting down MySQL.. [ OK ]
Starting MySQL. [ OK ]

mysql -u root -p
Enter password:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/data/var/lib/mysql/mysql.sock' (2)

mysql -u root -p --protocol tcp
Enter password:

mysql>

Could you please help me why mysql -u root -p is not allowing me to get inside the mysql prompt. But mysql -u root -p --protocol tcp is allowing me the access.

getenforce
Disabled

Kind regards,
Jojan Paul
 
Old 04-23-2014, 09:53 AM   #2
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7 / 8
Posts: 3,529

Rep: Reputation: 1593Reputation: 1593Reputation: 1593Reputation: 1593Reputation: 1593Reputation: 1593Reputation: 1593Reputation: 1593Reputation: 1593Reputation: 1593Reputation: 1593
check that /data/var/lib/mysql folder exists and that user mysql has ownership, if necessary shut down mysql, remove the mysql.sock file manually and try restarting mysql
 
Old 04-23-2014, 10:22 AM   #3
eklavya
Member
 
Registered: Mar 2013
Posts: 636

Rep: Reputation: 142Reputation: 142
Quote:
Originally Posted by jojanmpaul View Post
Could you please help me why mysql -u root -p is not allowing me to get inside the mysql prompt. But mysql -u root -p --protocol tcp is allowing me the access.
There should be a line under section [mysqld] in your my.cnf file and it should be commented or not there, it is
Code:
skip-networking
If you uncomment the line or if it is not there so you put it in your my.cnf under the section [mysqld] then you restart the mysql, even you will not be able to connect to mysql using
Code:
 mysql -u root -p --protocol tcp
Not listening on port TCP/IP can be a security enhancement, if all processes that need to connect to mysqld run on the same host.All interaction with mysqld must be made via Unix sockets or named pipes.

To start the mysql prompt using regular command, follow the solution of TenTenths.

Last edited by eklavya; 04-23-2014 at 10:47 AM.
 
Old 04-24-2014, 12:10 AM   #4
jojanmpaul
Member
 
Registered: Sep 2012
Location: Bangalore
Posts: 80

Original Poster
Rep: Reputation: Disabled
Hi,

After adding below line in my.cnf the issue has been resolved.

[mysqld]
socket = /data/var/lib/mysql/mysql.sock

Kind regards,
Jojan Paul
 
  


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
mysql connect remote as root works, user fails sir-lancealot Linux - Server 2 02-29-2012 10:50 AM
DBI connect failed : Access denied for user 'root'@'%' to database 'mysql' kwickcut Linux - Software 11 02-10-2012 03:26 PM
mysql db running on SUSE 10. Java code fails to connect from localhost Carlos2dub SUSE / openSUSE 1 07-04-2008 10:23 AM
Connect to mysql as non root(linux) user dublinclontarf Slackware 1 02-09-2004 05:19 AM

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

All times are GMT -5. The time now is 02:58 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