LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 01-12-2017, 12:15 PM   #1
TBotNik
Member
 
Registered: May 2016
Posts: 341

Rep: Reputation: Disabled
MySQL socket error!


All,

Keep getting the following errors, from MySQL via my server:

Code:
mysqli_connect(): (HY000/2002): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
All these errors started after I installed osticket, via it's HOWTO. Found out that it sets root to it's default password, so have to run a root_reset script, but even that is also giving this error now!

Bash Script root_reset.sh
Code:
#! /bin/bash 
# Script to reset ROOT & ADMIN MySQL passwords
# Must be run in the SUDO mode

service mysql stop;
#mysqld --skip-grant-tables < /Scripts/MySQL/root_reset.txt;
mysql --user=mysql < /Scripts/MySQL/root_reset.txt;
service mysql restart;
SQL input file root_reset.txt
Code:
FLUSH PRIVILEGES;
#SET PASSWORD FOR root@'localhost' = PASSWORD('newpass');
#UPDATE mysql.user SET Password=PASSWORD('newpass') WHERE User='root';
USE mysql;
UPDATE user SET Password = PASSWORD('newpass') WHERE Host = 'localhost' AND User = 'root';
UPDATE user SET Password = PASSWORD('newpass') WHERE Host = 'localhost' AND User = $USER;
UPDATE user SET Password = PASSWORD('newpass') WHERE Host = '%' AND User = 'root';
UPDATE user SET Password = PASSWORD('newpass') WHERE Host = '%' AND User = $USER;
FLUSH PRIVILEGES;

#ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';
quit;
Help please!

Cheers!

TBNK

Last edited by TBotNik; 01-12-2017 at 12:19 PM.
 
Old 01-12-2017, 03:15 PM   #2
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,237

Rep: Reputation: 1651Reputation: 1651Reputation: 1651Reputation: 1651Reputation: 1651Reputation: 1651Reputation: 1651Reputation: 1651Reputation: 1651Reputation: 1651Reputation: 1651
Output of:

Code:
ps auxw | grep mysql
stat /var/run/mysqld/mysqld.sock
cat /var/run/mysqld/mysqld.sock
 
Old 01-13-2017, 01:29 AM   #3
TBotNik
Member
 
Registered: May 2016
Posts: 341

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by szboardstretcher View Post
Output of:

Code:
ps auxw | grep mysql
stat /var/run/mysqld/mysqld.sock
cat /var/run/mysqld/mysqld.sock
szboardstretcher,

No such file as /var/run/mysqld/mysqld.sock or /var/run/mysqld/mysql.sock.

Matter of fact absolutely no .sock file at all on the system.

I'm on Kubuntu 14.04

Cheers!

TBNK
 
Old 01-14-2017, 07:53 AM   #4
TBotNik
Member
 
Registered: May 2016
Posts: 341

Original Poster
Rep: Reputation: Disabled
Script

All,

I have even run the following script in both the install and purge modes, but it does not fix my problem and version remains at 5.5.53.

Code:
#! /bin/bash 
# Script to reinstall MySQL completely
# Must be run in the SUDO mode

service mysql stop;

if [ "$1" == "purge*" ]; then
	#Purge method
	echo "Purging MySQL \n";
	apt-get -y -q remove --purge mysql-server mysql-client mysql-common;
	apt-get -y -q remove --purge mysql-client-core-5.5;
	apt-get autoremove && apt-get autoclean;
	rm -rf /var/lib/mysql
	apt-get update && apt-get upgrade;
	sudo apt-get install mysql-server-5.7 mysql-client mysql-common mysql-workbench
else
	echo "Reinstalling MySQL \n";
	apt-get -y -q install --reinstall mysql-server-5.7 mysql-client mysql-common mysql-workbench;
	apt-get autoremove && apt-get autoclean;
	apt-get update && apt-get upgrade;
fi 

service mysql start;
Need MySQL back! Was developing and started trying to call MySQL when errors started.

Cheers!

TBNK
 
Old 01-25-2017, 10:07 AM   #5
TBotNik
Member
 
Registered: May 2016
Posts: 341

Original Poster
Rep: Reputation: Disabled
Weird

All,

Im at a weird place with this. I have never been able to actually purge 5.5.53, and so that is what I always get when I run:
Code:
mysql --version
I'm thinking that in addition to my line:
Code:
rm -rf /var/lib/mysql
I also need the line:
Code:
rm -rf /etc/mysql
To make sure nothing there is pointing back to ver 5.5.53

The weird part is, though I never was successful with the upgrade from 5.5.53 to 5.7; I can now login to mysql from the cmd line for both root and $USER and permissions etc are there, but never can login via phpmyadmin anymore. That would suggest issues in/with the config.inc.php config file for phpmyadmin, but can not see any issues there, when editing.

Anyway your comments on these thoughts appreciated. Also I notice all the db files are still in the /var/lib/mysql directory so that also indicates that the "rm" command for that is not working from the script. Wonder if something in those db files, especially the "mysql" database are what keeps making it think its on 5.5.53?

Thanks & Cheers!

TBNK
 
Old 01-25-2017, 10:11 AM   #6
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,237

Rep: Reputation: 1651Reputation: 1651Reputation: 1651Reputation: 1651Reputation: 1651Reputation: 1651Reputation: 1651Reputation: 1651Reputation: 1651Reputation: 1651Reputation: 1651
Quote:
Wonder if something in those db files, especially the "mysql" database are what keeps making it think its on 5.5.53?
https://dev.mysql.com/doc/internals/...le-format.html

Check out the section on .frm files and the offset 0x33. This is the mysql version the table was built with. You can view it in your files with hexdump if you have it installed.
 
Old 01-25-2017, 10:47 AM   #7
TBotNik
Member
 
Registered: May 2016
Posts: 341

Original Poster
Rep: Reputation: Disabled
Repository needed

All,

The Muon Software Center, as most know is totally useless, so out of frustration installed "Synaptic Package Manager"! Looking in there, the latest available MySQL version is 5.6, so rather obvious why my upgrade is failing.

So knew I needed either new repository or .deb file for this. Found a HOWTO at:

Modified my script to:

Code:
#! /bin/bash 
# Script to reinstall MySQL completely
# Must be run in the SUDO mode

service mysql stop;

if [ "$1" == "purge*" ]; then
	#Purge method
	echo "Purging MySQL \n";
	apt-get -y -q remove --purge mysql-server-5.5.53 mysql-server-5.7 mysql-common;
	apt-get -y -q remove --purge mysql-client mysql-client-core-5.5;
	apt-get autoremove && apt-get autoclean;
	tar -zcvf /backups/MySQL/Var/"("$(date +%y-%m-%d)varlibfiles.tar.gz")" /var/lib/mysql;
	rm -rf /var/lib/mysql;
	rm -rf /etc/mysql;
	wget http://dev.mysql.com/get/mysql-apt-config_0.8.0-1_all.deb;
	dpkg -i mysql-apt-config_0.8.0-1_all.deb;
	apt-get update && apt-get upgrade;
	apt-get install mysql-server mysql-client mysql-common mysql-workbench;
	mysql_upgrade;
else
	echo "Reinstalling MySQL \n";
	apt-get -y -q install --reinstall mysql-server-5.7 mysql-client mysql-common mysql-workbench;
	apt-get autoremove && apt-get autoclean;
	apt-get update && apt-get upgrade;
	service mysql start;
fi
Running now to see what results I get!

Cheers!

TBNK
 
Old 01-27-2017, 12:35 AM   #8
yadheesh
LQ Newbie
 
Registered: May 2015
Location: Bangalore
Distribution: Cent-OS
Posts: 18

Rep: Reputation: Disabled
Hi,,


Even am also facing the same issue,, for that i use "fuser -k -n tcp 3306"

Use the command and Clear port Issue,, Surely the service ll get restart
 
Old 02-02-2017, 12:29 PM   #9
TBotNik
Member
 
Registered: May 2016
Posts: 341

Original Poster
Rep: Reputation: Disabled
All,

After trapping the install output an looking at it the following lines in my script:
Code:
        wget http://dev.mysql.com/get/mysql-apt-config_0.8.0-1_all.deb;
        dpkg -i mysql-apt-config_0.8.0-1_all.deb; 
        apt-get update && apt-get upgrade;
        apt-get -y -q install mysql-server mysql-client mysql-common mysql-workbench;
        mysql_upgrade;
Always choose version 5.5.56 instead of 5.7, so until I can get the right code to download with the "wget" cmd, then nothing will work right!

Cheers!

TBNK
 
Old 02-02-2017, 03:18 PM   #10
TBotNik
Member
 
Registered: May 2016
Posts: 341

Original Poster
Rep: Reputation: Disabled
Another

All,

Found another HOWTO and changed my code to:

Code:
#! /bin/bash 
# Script to reinstall MySQL completely
# Must be run in the SUDO mode

service mysql stop;
fuser -k -n tcp 3306;

if [ "$1" == "purge*" ]; then
	#Purge method
	echo "Purging MySQL! \n";
	apt-get -y -q remove --purge mysql-server-5.5.53 mysql-server-5.7 mysql-common;
	apt-get -y -q remove --purge mysql-client mysql-client-core-5.5;
	apt-get autoremove && apt-get autoclean;
	tar -zcvf /backups/MySQL/Var/"("$(date +%y-%m-%d)varlibfiles.tar.gz")" /var/lib/mysql;
	rm -rf /var/lib/mysql;
	rm -rf /etc/mysql;
	
	echo "Installing MySQL 5.7! \n";
	# wget http://dev.mysql.com/get/mysql-apt-config_0.8.0-1_all.deb;
	wget http://dev.mysql.com/get/mysql-apt-config_0.3.2-1ubuntu14.04_all.deb;
	# dpkg -i mysql-apt-config_0.8.0-1_all.deb;
	dpkg -i mysql-apt-config_0.3.2-1ubuntu14.04_all.deb;
	apt-get -y -q update && apt-get -y -q upgrade;
	# apt-get -y -q install mysql-server mysql-client mysql-common mysql-workbench;
	apt-get -y -q install mysql-server-5.7 mysql-client mysql-common mysql-workbench;
	mysql_upgrade -u root -pnomened1497 --force;
else
	echo "Reinstalling MySQL \n";
	apt-get -y -q install --reinstall mysql-server-5.7 mysql-client mysql-common mysql-workbench;
	apt-get autoremove && apt-get autoclean;
	apt-get update && apt-get upgrade;
	service mysql start;
fi
But none of these have a repository so the line:

Code:
apt-get -y -q install mysql-server-5.7 mysql-client mysql-common mysql-workbench;
Keeps erroring with the message:

Quote:
E: Unable to locate package mysql-server-5.7
E: Couldn't find any package by regex 'mysql-server-5.7'
So without an actual repository entry in the "/etc/apt/sources.list" file this will never install.

Still looking for that. If you know it or have it please share!

Cheers!

TBNK
 
Old 02-02-2017, 04:40 PM   #11
TBotNik
Member
 
Registered: May 2016
Posts: 341

Original Poster
Rep: Reputation: Disabled
DPKG Fails

All,

Additionally the 5.7 resource that the dpkg install is looking for, no longer exists, so the dpkg screen opens, but hangs, because the resource can not be found. My Magento says I need 5.7, so really have to get this installed.

However, I'm running the upgrade from 5.5.53 to 5.6, through synaptic package manager, but even that is erroring, so not sure what to do next!

Cheers!

TBNK
 
Old 02-04-2017, 05:43 PM   #12
TBotNik
Member
 
Registered: May 2016
Posts: 341

Original Poster
Rep: Reputation: Disabled
Works on new install

All,

OK! Had to do new Kubuntu 14.04 LTS install on my laptop, due to it dying all the time.

See: http://www.linuxquestions.org/questi...ts-4175596797/

When this come to the mysql install, the dpkg, though totally written wrong (keeps you in a loop, till you figure out what it's looking for), infact does have and installs MySQL 5.7, from the native ubuntu repositories.

I called it with the code:

Code:
        echo " ";
        echo "Getting MySQL 5.7 source!";
        wget http://dev.mysql.com/get/mysql-apt-config_0.8.0-1_all.deb;
        echo " ";
        echo "Installing MySQL 5.7!";
        dpkg -i mysql-apt-config_0.8.0-1_all.deb;
        apt-get -y -q update && apt-get -y -q upgrade;
        apt-get -y -q install mysql-server mysql-client mysql-common mysql-workbench;
        mysql_upgrade -u root -pyouradminpwd --force;
Retrying this again on the server. Let you know how it goes.
 
  


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. suziecorbett Linux - Software 8 10-09-2008 01:52 AM
ERROR 2002: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql. SpellChainz Linux - Software 3 06-28-2007 11:46 AM
mysql error Can't connect to local MySQL server through socket '/var/lib/mysql/mysql. SpellChainz Linux - Newbie 1 06-23-2007 03:35 PM
mysql error Can't connect to local MySQL server through socket '/var/lib/mysql/mysql. Dannux Linux - Software 3 03-24-2006 08:44 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

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