LinuxQuestions.org
Review your favorite Linux distribution.
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 05-31-2018, 12:24 AM   #1
DennyY
Member
 
Registered: May 2018
Location: San Francisco, CA
Distribution: CentOS 7
Posts: 76

Rep: Reputation: 1
Question Can't connect to mysql server


Hi All,

I was trying to logon to mysql:

$mysql -u root -p
$passwd:

###this is what I got###
Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

By the way, mariadb.service is up and running.

Please help me solve this issue.

Thank you,
Denny
 
Old 05-31-2018, 03:21 AM   #2
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 12,631

Rep: Reputation: 1808Reputation: 1808Reputation: 1808Reputation: 1808Reputation: 1808Reputation: 1808Reputation: 1808Reputation: 1808Reputation: 1808Reputation: 1808Reputation: 1808
Quote:
Originally Posted by DennyY View Post
Hi All,

I was trying to logon to mysql:

$mysql -u root -p
$passwd:

###this is what I got###
Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

By the way, mariadb.service is up and running.

Please help me solve this issue.

Thank you,
Denny
You should give more details, like distro, version, how you've installed mariaDB, etc.
In the meantime you can check /etc/my.cnf and/or run:
Code:
ps axu|grep mysqld
to find the socket location.
 
1 members found this post helpful.
Old 05-31-2018, 08:12 PM   #3
DennyY
Member
 
Registered: May 2018
Location: San Francisco, CA
Distribution: CentOS 7
Posts: 76

Original Poster
Rep: Reputation: 1
Question Mysql socket issue

Hi,

So as you know, I was trying to logon to mysql:

$mysql -u root -p
$passwd:

###this is what I get###
Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

By the way, mariadb.service is up and running. When I typed mysqlshow, I see my Databases on my DHCP server station.

And so I did this like you suggested:

# ps axu | grep mysqld
root 3800 0.0 0.0 112704 972 pts/0 S+ 16:55 0:00 grep --color=auto mysqld


But the socket looks ok, no?

Sorry, still fairly new to sockets.

Thanks again for your help,
Denny










Quote:
Originally Posted by bathory View Post
You should give more details, like distro, version, how you've installed mariaDB, etc.
In the meantime you can check /etc/my.cnf and/or run:
Code:
ps axu|grep mysqld
to find the socket location.
 
Old 05-31-2018, 08:21 PM   #4
scasey
Senior Member
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.7.1908
Posts: 4,373

Rep: Reputation: 1538Reputation: 1538Reputation: 1538Reputation: 1538Reputation: 1538Reputation: 1538Reputation: 1538Reputation: 1538Reputation: 1538Reputation: 1538Reputation: 1538
Quote:
Originally Posted by DennyY View Post
And so I did this like you suggested:

# ps axu | grep mysqld
root 3800 0.0 0.0 112704 972 pts/0 S+ 16:55 0:00 grep --color=auto mysqld
That's showing you the grep command only. It doesn't look as if mysqld is running.
What does
Code:
systemctl status mysqld
show?
 
Old 05-31-2018, 09:02 PM   #5
DennyY
Member
 
Registered: May 2018
Location: San Francisco, CA
Distribution: CentOS 7
Posts: 76

Original Poster
Rep: Reputation: 1
Question mysql and mariadb

Hi Sean,

Thank you for the reply.

So here is what's happening:

DHCP has mariadb-server. It's up and running, and I can see the Databases when I typed mysqlshow.

Now I am using my DHCP client. I have also installed mariadb.

### Package 1:mariadb-5.5.56-2.el7.x86_64 already installed and latest version ###

But when I did systemctl status mysqld:

Unit mysqld.service could not be found.

This is a DHCP client station. My impression is that since the mariadb-server is up and running, I am supposed to be able to connect through it, and start using mariadb on the client station, no? Am I supposed to install mariadb-server on the client station as well?

Please advise,
Denny







Quote:
Originally Posted by scasey View Post
That's showing you the grep command only. It doesn't look as if mysqld is running.
What does
Code:
systemctl status mysqld
show?
 
Old 05-31-2018, 09:24 PM   #6
michaelk
Moderator
 
Registered: Aug 2002
Posts: 19,523

Rep: Reputation: 3135Reputation: 3135Reputation: 3135Reputation: 3135Reputation: 3135Reputation: 3135Reputation: 3135Reputation: 3135Reputation: 3135Reputation: 3135Reputation: 3135
A remote client can connect to MariaDB over the network but by default the server is configured for local access only. systemctl status will only show status on the computer your running the command from unless you specify a different host.

In a nutshell

The server needs to be configured so it will listen to all network interfaces.

A MariaDB user needs to be granted access over the network.

The firewall if running it needs to allow MariaDB traffic which is port 3306 by default.

https://mariadb.com/kb/en/library/co...client-access/
 
1 members found this post helpful.
  


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
ERROR 2002: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql. NoviceW Linux - Networking 17 09-17-2014 03:13 PM
ERROR 2002: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql. SpellChainz Linux - Software 3 06-28-2007 12:46 PM
mysql error Can't connect to local MySQL server through socket '/var/lib/mysql/mysql. SpellChainz Linux - Newbie 1 06-23-2007 04:35 PM
mysql error Can't connect to local MySQL server through socket '/var/lib/mysql/mysql. Dannux Linux - Software 3 03-24-2006 09:44 AM

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

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