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 09-03-2012, 09:47 PM   #16
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

Ubuntu systems with mysql installed have a special mysql user for update purposes that you can use to login and do maintenance.

With the mysql daemon running, in a terminal
Code:
mysql -u debian-sys-maint -p
In another terminal, 'cat' the file /etc/mysql/debian.cnf. That file contains the password for the debian-sys-masint user; paste that password when prompted for it.

You should now have gained access and this user has the same privileges as the root user.

Assuming the mysql root user is still existing, you can set a password using
Code:
update user set password=password('yourpassword') where user='root'
If the mysql root user no longer exists, use below to create the account
Code:
grant all privileges on *.* to 'root'@'localhost' identified by 'yourpassword' with grant option
Don't forget to flush the privileges before quiting the client.


PS
Not sure how much damage has been done by now, but above would work on a 'normal' install.

Last edited by Wim Sturkenboom; 09-03-2012 at 09:49 PM.
 
Old 09-03-2012, 09:52 PM   #17
southpointingchariot
Member
 
Registered: Sep 2012
Posts: 31

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Wim Sturkenboom View Post
Ubuntu systems with mysql installed have a special mysql user for update purposes that you can use to login and do maintenance.

With the mysql daemon running, in a terminal
Code:
mysql -u debian-sys-maint -p
In another terminal, 'cat' the file /etc/mysql/debian.cnf. That file contains the password for the debian-sys-masint user; paste that password when prompted for it.

You should now have gained access and this user has the same privileges as the root user.

Assuming the mysql root user is still existing, you can set a password using
Code:
update user set password=password('yourpassword') where user='root'
If the mysql root user no longer exists, use below to create the account
Code:
grant all privileges on *.* to 'root'@'localhost' identified by 'yourpassword' with grant option
Don't forget to flush the privileges before quiting the client.


PS
Not sure how much damage has been done by now, but above would work on a 'normal' install.
When I run "mysql -u debian-sys-maint -p" I get "ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)"

As to the amount of damage, its probably a lot
 
Old 09-03-2012, 09:53 PM   #18
sag47
Senior Member
 
Registered: Sep 2009
Location: Orange County, CA
Distribution: Kubuntu x64, Raspbian, CentOS
Posts: 1,832
Blog Entries: 36

Rep: Reputation: 451Reputation: 451Reputation: 451Reputation: 451Reputation: 451
Quote:
Originally Posted by southpointingchariot View Post
Alas, we have a problem on the earlier step. When I run "service mysql start", I get "start: Job failed to start"
Does /var/log/mysql.err or /var/log/mysql.log indicate what the problem could be? It may be that another process is listening on the socket. If so we'll need to kill it.

Code:
netstat -nlp | grep 3306
#you should see something like the following line.
#tcp        0      0 127.0.0.1:3306          0.0.0.0:*               LISTEN      1456/mysqld
#Let's kill the process using it's pid (process ID).
kill -15 1456
#run the netstat command again, if the process does not go away after a while of running the netstat command then issue a force kill.
kill -9 1456
#try starting the mysql service again
service mysql start
 
Old 09-03-2012, 09:57 PM   #19
southpointingchariot
Member
 
Registered: Sep 2012
Posts: 31

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by sag47 View Post
Does /var/log/mysql.err or /var/log/mysql.log indicate what the problem could be? It may be that another process is listening on the socket. If so we'll need to kill it.

Code:
netstat -nlp | grep 3306
#you should see something like the following line.
#tcp        0      0 127.0.0.1:3306          0.0.0.0:*               LISTEN      1456/mysqld
#Let's kill the process using it's pid (process ID).
kill -15 1456
#run the netstat command again, if the process does not go away after a while of running the netstat command then issue a force kill.
kill -9 1456
#try starting the mysql service again
service mysql start
Opening mysql.err and mysql.log in vim reveals empty files.

Running "netstat -nlp | grep 3306" returns nothing.

And farther down the rabbit hole we go .
 
Old 09-03-2012, 09:59 PM   #20
sag47
Senior Member
 
Registered: Sep 2009
Location: Orange County, CA
Distribution: Kubuntu x64, Raspbian, CentOS
Posts: 1,832
Blog Entries: 36

Rep: Reputation: 451Reputation: 451Reputation: 451Reputation: 451Reputation: 451
Code:
sudo apt-get purge mysql-server
sudo apt-get remove msyql-server
sudo apt-get install mysql-server
Let's try that way then. The "dmesg" command might indicate what could be going wrong as well.
 
Old 09-03-2012, 10:01 PM   #21
southpointingchariot
Member
 
Registered: Sep 2012
Posts: 31

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by sag47 View Post
Code:
sudo apt-get purge mysql-server
sudo apt-get remove msyql-server
sudo apt-get install mysql-server
Let's try that way then. The "dmesg" command might indicate what could be going wrong as well.
"sudo apt-get remove msyql-server" returns "E: Unable to locate package msyql-server". Isn't this logical concerning we just purged it?
 
Old 09-03-2012, 10:01 PM   #22
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
Quote:
When I run "mysql -u debian-sys-maint -p" I get "ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)"
Your daemon is not running; the netstat command also shows that.
 
Old 09-03-2012, 10:02 PM   #23
sag47
Senior Member
 
Registered: Sep 2009
Location: Orange County, CA
Distribution: Kubuntu x64, Raspbian, CentOS
Posts: 1,832
Blog Entries: 36

Rep: Reputation: 451Reputation: 451Reputation: 451Reputation: 451Reputation: 451
That's because it's spelled wrong, double check spelling, and try again. Should by mysql-server, and not msyql-server.
 
Old 09-03-2012, 10:05 PM   #24
southpointingchariot
Member
 
Registered: Sep 2012
Posts: 31

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by sag47 View Post
That's because it's spelled wrong, double check spelling, and try again. Should by mysql-server, and not msyql-server.
Ah, of course. It appears the installation was successful. Do I proceed with your earlier comment?
 
Old 09-03-2012, 10:12 PM   #25
sag47
Senior Member
 
Registered: Sep 2009
Location: Orange County, CA
Distribution: Kubuntu x64, Raspbian, CentOS
Posts: 1,832
Blog Entries: 36

Rep: Reputation: 451Reputation: 451Reputation: 451Reputation: 451Reputation: 451
Quote:
Originally Posted by southpointingchariot View Post
Ah, of course. It appears the installation was successful. Do I proceed with your earlier comment?
Yes, hopefully with that everything should be okay. You might need to start the server,
Code:
sudo service mysql start
 
Old 09-03-2012, 10:15 PM   #26
southpointingchariot
Member
 
Registered: Sep 2012
Posts: 31

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by sag47 View Post
Yes, hopefully with that everything should be okay. You might need to start the server,
Code:
sudo service mysql start
Sigh, and we're back to "start: Job failed to start".

In case I'm missing something, the return from "sudo apt-get install mysql-server" was:
Quote:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
mysql-server
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/11.7 kB of archives.
After this operation, 115 kB of additional disk space will be used.
Selecting previously unselected package mysql-server.
(Reading database ... 285829 files and directories currently installed.)
Unpacking mysql-server (from .../mysql-server_5.5.24-0ubuntu0.12.04.1_all.deb) ...
Setting up mysql-server (5.5.24-0ubuntu0.12.04.1) ...
root@jane:/var/log#
 
Old 09-03-2012, 10:18 PM   #27
sag47
Senior Member
 
Registered: Sep 2009
Location: Orange County, CA
Distribution: Kubuntu x64, Raspbian, CentOS
Posts: 1,832
Blog Entries: 36

Rep: Reputation: 451Reputation: 451Reputation: 451Reputation: 451Reputation: 451
The only thing I can think of left is maybe removing the /var/lib/mysql directory entirely.
Code:
#double check the path!  And double check it's not important!
sudo rm -rf /var/lib/mysql
Then try to start the mysql server again. Not unless you can give us more log information from dmesg or other mysql related log files.
 
Old 09-03-2012, 10:19 PM   #28
southpointingchariot
Member
 
Registered: Sep 2012
Posts: 31

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by sag47 View Post
The only thing I can think of left is maybe removing the /var/lib/mysql directory entirely.
Code:
#double check the path!  And double check it's not important!
sudo rm -rf /var/lib/mysql
Then try to start the mysql server again. Not unless you can give us more log information from dmesg or other mysql related log files.
To make 100% totally sure, does it matter what directory I'm in when I run this?

This part feels like brain-surgery by phone - and I'm the guy with the knife!
 
Old 09-03-2012, 10:20 PM   #29
sag47
Senior Member
 
Registered: Sep 2009
Location: Orange County, CA
Distribution: Kubuntu x64, Raspbian, CentOS
Posts: 1,832
Blog Entries: 36

Rep: Reputation: 451Reputation: 451Reputation: 451Reputation: 451Reputation: 451
It does not matter the directory you're in. Except do not be in the directory /var/lib/mysql. Be in any directory but that one.
 
Old 09-03-2012, 10:22 PM   #30
sag47
Senior Member
 
Registered: Sep 2009
Location: Orange County, CA
Distribution: Kubuntu x64, Raspbian, CentOS
Posts: 1,832
Blog Entries: 36

Rep: Reputation: 451Reputation: 451Reputation: 451Reputation: 451Reputation: 451
Also, forgot to mention but might want to try,
Code:
chown -R mysql\: /var/lib/mysql
 
  


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
LXer: How To Install LAMP Server in Ubuntu Server 12.04 LTS LXer Syndicated Linux News 0 05-20-2012 01:45 AM
Centos LAMP Server with unidentified script causing server to port scan ZS- Linux - Security 48 01-30-2011 08:27 AM


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