LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 11-27-2016, 04:13 PM   #1
Garrett85
Member
 
Registered: Jan 2011
Posts: 299

Rep: Reputation: 5
MariaDB - password reset


I'm trying to reset my mariadb password following this site -> https://www.rosehosting.com/blog/how...root-password/
but when I enter mysql -u root I get the following error:

Code:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2 "No such file or directory")
Any ideas? Thanks.
 
Old 11-27-2016, 04:40 PM   #2
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=14, FreeBSD_12{.0|.1}
Posts: 5,616
Blog Entries: 11

Rep: Reputation: 3655Reputation: 3655Reputation: 3655Reputation: 3655Reputation: 3655Reputation: 3655Reputation: 3655Reputation: 3655Reputation: 3655Reputation: 3655Reputation: 3655
Your mysql server is not running.

Did this...

Code:
# mysqld_safe --skip-grant-tables &
... produce any errors?
 
Old 11-27-2016, 05:19 PM   #3
Garrett85
Member
 
Registered: Jan 2011
Posts: 299

Original Poster
Rep: Reputation: 5
Quote:
Originally Posted by astrogeek View Post
Your mysql server is not running.

Did this...

Code:
# mysqld_safe --skip-grant-tables &
... produce any errors?
user@mothership ~ $ service mysql stop
user@mothership ~ $ mysqld_safe --skip-grant-tables &
[1] 6576
user@mothership ~ $ 161127 17:16:39 mysqld_safe Logging to syslog.
161127 17:16:39 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
161127 17:16:39 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended

[1]+ Done mysqld_safe --skip-grant-tables
user@mothership ~ $ mysql -u root
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2 "No such file or directory")

The blank line you see between mysql.pd ended and the [1]+ Done, that was just a blinking cursor until I hit enter. Any ideas? Thanks.
 
Old 11-27-2016, 05:49 PM   #4
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,325

Rep: Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757
Could you check if you have /etc/my.cnf or /etc/my.cnf.d/server.cnf configuration file?

Then look for a line like:
Code:
socket = /var/run/mysql/mysqld.sock
Check if it is mysql.sock or mysqld.sock and the path

Then list /var/run/mysql and /var/lib/mysql directories
 
Old 11-27-2016, 06:17 PM   #5
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=14, FreeBSD_12{.0|.1}
Posts: 5,616
Blog Entries: 11

Rep: Reputation: 3655Reputation: 3655Reputation: 3655Reputation: 3655Reputation: 3655Reputation: 3655Reputation: 3655Reputation: 3655Reputation: 3655Reputation: 3655Reputation: 3655
What keefaz says, but...

Code:
161127 17:16:39 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
That says that it ended prematurely.

Check the log file and see what it says.

You my need to start with mysqld_safe using the --datadir and --pid-file options, something like this (with your actual system paths)

Code:
mysqld_safe --datadir=/var/lib/mysql --pid-file=/var/run/mysql/mysql.pid --skip-grant-tables &

Last edited by astrogeek; 11-27-2016 at 06:25 PM. Reason: Shouldn't post when otherwise busy...
 
Old 11-27-2016, 07:46 PM   #6
Garrett85
Member
 
Registered: Jan 2011
Posts: 299

Original Poster
Rep: Reputation: 5
socket

Quote:
Originally Posted by keefaz View Post
Could you check if you have /etc/my.cnf or /etc/my.cnf.d/server.cnf configuration file?

Then look for a line like:
Code:
socket = /var/run/mysql/mysqld.sock
Check if it is mysql.sock or mysqld.sock and the path

Then list /var/run/mysql and /var/lib/mysql directories
I found that line and it's in /etc/mysql/mariadb.conf.d/50-mysqld_safe.cnf
and it reads
Code:
socket		= /var/run/mysqld/mysqld.sock
 
Old 11-27-2016, 07:54 PM   #7
Garrett85
Member
 
Registered: Jan 2011
Posts: 299

Original Poster
Rep: Reputation: 5
Update

I don't know what this means but I just navigated to /var/run/mysqld/ and there is not mysqld.sock file there, or any other file apart from . & .. But I'm sure I don't know what I'm talking about.
 
Old 11-27-2016, 09:03 PM   #8
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=14, FreeBSD_12{.0|.1}
Posts: 5,616
Blog Entries: 11

Rep: Reputation: 3655Reputation: 3655Reputation: 3655Reputation: 3655Reputation: 3655Reputation: 3655Reputation: 3655Reputation: 3655Reputation: 3655Reputation: 3655Reputation: 3655
OK, lets back up a step and ask all the right questions...

What distro and version is this?

Is this on a remote VPS or a local system?

What version of MariaDB or MySQL?

Does this mysql server start normally? Do service mysql start/stop report success?
 
Old 11-28-2016, 07:11 PM   #9
Garrett85
Member
 
Registered: Jan 2011
Posts: 299

Original Poster
Rep: Reputation: 5
MariaDB

Quote:
Originally Posted by astrogeek View Post
OK, lets back up a step and ask all the right questions...

What distro and version is this?

Is this on a remote VPS or a local system?

What version of MariaDB or MySQL?

Does this mysql server start normally? Do service mysql start/stop report success?
I just re-installed Linux Mint 18 (Cinnamon) over Mint 17 and I'm trying to get all my file and packages working again. This is running on localhost and I couldn't really tell you how it's been running since I've just got it installed on Mint 18. I also can't be sure of the version but I think it's MariaDB 10.
 
Old 11-28-2016, 08:34 PM   #10
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=14, FreeBSD_12{.0|.1}
Posts: 5,616
Blog Entries: 11

Rep: Reputation: 3655Reputation: 3655Reputation: 3655Reputation: 3655Reputation: 3655Reputation: 3655Reputation: 3655Reputation: 3655Reputation: 3655Reputation: 3655Reputation: 3655
Quote:
Originally Posted by Garrett85 View Post
I just re-installed Linux Mint 18 (Cinnamon) over Mint 17 and I'm trying to get all my file and packages working again. This is running on localhost and I couldn't really tell you how it's been running since I've just got it installed on Mint 18. I also can't be sure of the version but I think it's MariaDB 10.
So, if it was a reinstall then it is most likely that MySQL ws never initialized on this machine. If so, this isn't a password change problem but a database initialization problem.

If you are sure that you had data in the MySQL database on the old Mint and did not reformat the drive for the new Mint, we will need to find that first and back it up - so decide this first.

If you had no old data to save or reformatted the drive we really just need to initialize the database and get it started.

To do that you will need to run mysql_install_db, then get it started with mysqld_safe.

I am not a Mint user, so you may want to check their docs specific to your version.

We already know it is installed because mysqld_safe is trying to start, so we just need to initialize it and start the server.

The basic steps common to most distros are, as root...

Code:
/usr/bin/mysql_install_db --user=mysql

 ... then start the server with... 

/usr/bin/mysqld_safe 

 ...once it is running, run...

/usr/bin/mysql_secure_installation
When you run mysql_secure_installation you will get the chance to set the root password.

Last edited by astrogeek; 11-28-2016 at 08:38 PM. Reason: typos
 
Old 11-28-2016, 08:50 PM   #11
Garrett85
Member
 
Registered: Jan 2011
Posts: 299

Original Poster
Rep: Reputation: 5
Okay I'll give that a try. In the past I have just installed MariaDB on my new machine and sourced what few db projects I had exported before I wiped out my machine. Mostly just a few small databases from courses I'm following on udemy.com
 
Old 11-28-2016, 08:50 PM   #12
Garrett85
Member
 
Registered: Jan 2011
Posts: 299

Original Poster
Rep: Reputation: 5
But of course I can't source my exported files if I can't even login.
 
Old 11-28-2016, 11:26 PM   #13
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=14, FreeBSD_12{.0|.1}
Posts: 5,616
Blog Entries: 11

Rep: Reputation: 3655Reputation: 3655Reputation: 3655Reputation: 3655Reputation: 3655Reputation: 3655Reputation: 3655Reputation: 3655Reputation: 3655Reputation: 3655Reputation: 3655
Quote:
Originally Posted by Garrett85 View Post
I just re-installed Linux Mint 18 (Cinnamon) over Mint 17 and I'm trying to get all my file and packages working again. This is running on localhost and I couldn't really tell you how it's been running since I've just got it installed on Mint 18. I also can't be sure of the version but I think it's MariaDB 10.
That would have been a pretty important thing to mention in your initial problem description, by the way. Please review the Site FAQ for guidance on asking complete questions as that will help us help you as efficiently as possible.

You can check version whether it is running or not:

Code:
mysql --version
You have not yet told us...

* What the log says when you try to start with mysqld_safe as mentioned above
* Whether it starts normally or not which would confirm whether it has ever been started on this installation

So we still don't know whether it has ever been initialized or not, even though I suspect it has not.

Quote:
Originally Posted by Garrett85 View Post
Okay I'll give that a try. In the past I have just installed MariaDB on my new machine and sourced what few db projects I had exported before I wiped out my machine. Mostly just a few small databases from courses I'm following on udemy.com
This says that you did export all your valuable data and wiped the machine before reinstalling.

In other words, you do have backups of your data...? How did you export those, mysqldump?

And the initialization method I posted above is a general case for MySQL with several possible options - it is not copy/paste code. Please see your distro's documentation for your case.

Quote:
Originally Posted by Garrett85 View Post
But of course I can't source my exported files if I can't even login.
And you can't login unless the server is running, and the server cannot run until it has been initialized...
 
Old 11-30-2016, 07:09 PM   #14
Garrett85
Member
 
Registered: Jan 2011
Posts: 299

Original Poster
Rep: Reputation: 5
user@mothership ~ $ mysql --version
mysql Ver 15.1 Distrib 10.0.27-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2


user@mothership ~ $ mysqld_safe
161130 19:04:19 mysqld_safe Logging to syslog.
cat: /var/run/mysqld/mysqld.pid: Permission denied
rm: cannot remove '/var/run/mysqld/mysqld.pid': Permission denied
161130 19:04:19 mysqld_safe Fatal error: Can't remove the pid file:
/var/run/mysqld/mysqld.pid
Please remove it manually and start /usr/bin/mysqld_safe again;
mysqld daemon not started

user@mothership ~ $ sudo mysqld_safe
[sudo] password for user:
161130 19:04:30 mysqld_safe Logging to syslog.
161130 19:04:30 mysqld_safe A mysqld process already exists
user@mothership ~ $

No I don't think it's ever been started since my new installation of Mint 18 over Mint 17. I used phpmyadmin to export my databases.
 
Old 11-30-2016, 09:23 PM   #15
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=14, FreeBSD_12{.0|.1}
Posts: 5,616
Blog Entries: 11

Rep: Reputation: 3655Reputation: 3655Reputation: 3655Reputation: 3655Reputation: 3655Reputation: 3655Reputation: 3655Reputation: 3655Reputation: 3655Reputation: 3655Reputation: 3655
Quote:
Originally Posted by Garrett85 View Post
user@mothership ~ $ mysql --version
mysql Ver 15.1 Distrib 10.0.27-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2
Thanks, that helps and confirms it is installed.

Quote:
Originally Posted by Garrett85 View Post
user@mothership ~ $ sudo mysqld_safe
[sudo] password for user:
161130 19:04:30 mysqld_safe Logging to syslog.
161130 19:04:30 mysqld_safe A mysqld process already exists
user@mothership ~ $
That would definitely indicate that it is running, or has been started and killed leaving the pid file behind.

So, let's verify that one way or the other. What does this say (as root, or sudo if necessary)?

Code:
ps aux |grep mysqld
That will tell us if the process is running, and what parameters were used to start it.

Then as asked previously, does it start and stop normally? That is, do these produce any error/success messages?

Code:
service mysqld start
service mysqld stop
Form there we can plot the path to the desired end.

Quote:
Originally Posted by Garrett85 View Post
No I don't think it's ever been started since my new installation of Mint 18 over Mint 17. I used phpmyadmin to export my databases.
OK, as I recall PHPMyAdmin uses mysqldump. I was mostly looking for some confidence that your data were safe and usable.

Also, please place your code snippets inside [CODE]...[/CODE] tags for better readability. You may type those yourself or click the "#" button in the edit controls.
 
  


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
[SOLVED] centos 5.5 need to reset gui password not the root password jmiller Linux - Newbie 9 01-10-2015 05:40 PM
LXer: How to reset a root password in MariaDB on Linux LXer Syndicated Linux News 0 06-18-2014 02:51 AM
Freenode webchat invalid password msg - How to reset freenode password? codeslayer2010 General 1 02-01-2013 06:31 PM
Linux 2.6.15.1 The password lost , RESET PASSWORD ANDYCHAN Linux - General 2 08-18-2012 08:05 AM
How to retrieve( or reset) root password in Mandrake Linux, as I forgot my password? Reghunath Linux - Software 4 05-08-2008 04:11 AM

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

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