LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 03-19-2010, 08:46 PM   #1
lpallard
Member
 
Registered: Nov 2008
Posts: 985

Rep: Reputation: Disabled
Question MySQL problems...


Hi! recently installed Slack 13 on a machine (installed everything) and I am trying to configure MySQL out of the box... It doesnt work. Basically, I cant set the password for root. Originally, it is blank, but I would like, for security reasons, to set a password. The problem is that whenever I try (from command line, from Mysqlcc, webmin, etc) I am refused permission to set the password. I also tried using "mysql_secure_installation" and whenever I am asked for the current root's psw, I simply press enter (because it is blank), but when I enter the new password, the program says:
Code:
ERROR 1142 (42000) at line 1: UPDATE command denied to user ''@'localhost' for table 'user'
Password update failed
!

Mysqlcc interface does let me connect to the server (using a blank password) but whenever I try to access the "users" section, I am told You don't have enough privileges to access this section

This is very irritating... Any idea why that happens??? I reinstalled mysql using slackpkg reinstall mysql, but no luck so far...

any idea would be very appreciated.
Thanks!
 
Old 03-19-2010, 10:18 PM   #2
smoker
Senior Member
 
Registered: Oct 2004
Distribution: Fedora Core 4, 12, 13, 14, 15, 17
Posts: 2,279

Rep: Reputation: 249Reputation: 249Reputation: 249
What was your command line command to change the password ?
 
Old 03-19-2010, 10:58 PM   #3
lpallard
Member
 
Registered: Nov 2008
Posts: 985

Original Poster
Rep: Reputation: Disabled
First thanks for your reply!

To answer your question, I first stopped the mysqld service (using the script with the option "stop"), and then restarted with the command:

"mysqld_safe --skip-grant-tables &"

then I connected to the client with: "mysql -u root" which worked (so far)
At the mysql> prompt I entered in this order:

>use mysql;
>update user set password=PASSWORD("new-password") where User='root';
>flush privileges;
>quit

and then I got to the terminal where I stopped the service and restarted it.

Then the problem occured: I tried to connect to the client with:
"mysql -u root -p" and got the error:
"Access denied for user 'root'@'localhost' (using password: YES)"

BUT if I try with NO password, I can connect to the client....

It seems that whatever I do, it is not saved where it should be... Maybe permissions?? I did not change a single permission on anything, everything is out of the box like I said.

The same behavior happens with Mysqlcc... I can connect to the server, using NO password, but if I specify a password, it blocks me. However, even as root (globally in the OS) I cant access the "Users" section of Mysqlcc... it is refused no matter if I specify a password or not...

Hope this helps...

Thanks!

Last edited by lpallard; 03-19-2010 at 11:02 PM.
 
Old 03-19-2010, 11:16 PM   #4
smoker
Senior Member
 
Registered: Oct 2004
Distribution: Fedora Core 4, 12, 13, 14, 15, 17
Posts: 2,279

Rep: Reputation: 249Reputation: 249Reputation: 249
To change the root password enter :

mysqladmin -u root -p password <password>

where password is the actual word password
and <password> is your desired new password

You will be prompted for the current password.
If it's blank just hit enter.
You should go straight back to a shell prompt if it was successful.

You don't have to stop any services to do this.
 
Old 03-20-2010, 08:51 AM   #5
lpallard
Member
 
Registered: Nov 2008
Posts: 985

Original Poster
Rep: Reputation: Disabled
Exclamation

smoker, so I entered:

Code:
mysqladmin -u root -p password
and got

Code:
Enter password:
I pressed enter but I received:

Code:
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: YES)'
Also I tried

Code:
mysqladmin -u root -p password mysqlsrv
(note that mysqlsrv was the new password I was hoping to use)

but if I pressed enter instead of supplying a password, I was getting

Code:
mysqladmin: Can't turn off logging; error: 'Access denied; you need the SUPER privilege for this operation'
If I entered a password (lets say mysqlsrv), I was getting the same error as the first attempt....

Anybody understand whats going on?

Thanks for your support!
 
Old 03-20-2010, 09:30 AM   #6
lpallard
Member
 
Registered: Nov 2008
Posts: 985

Original Poster
Rep: Reputation: Disabled
Question

This is really weird... to follow up with my previous post, I finally managed (I think) to set the root password and now I am required to use it to log in as root, a blank password will no longer do it). Just to clarify, the reason why I could not set the root password had something to do with the socket files... I noticed that whenever I called the stop script (/etc/rc.d/rc.mysqld stop) I would still have mysqld processes running... I have to use killall mysqld& to kill them all. Once i did that, I was able to start the service with the --skip-grant-tables option and do my job.

I read on some forums that the problem I had was related to the fact that there is a anonymous user by default in the installation. The guy on that forum deleted the anonymous user and everything worked fine. I tried to do that, but the more I play around with that, the more I have the impression that the MYsql server does not even know that I am root... what I mean by that is that when I connect as root (mysql --user=root -p) and login using the password I successfully set, I get the "mysql>" prompt, but whenever I try to delete the anonymous user, I obtain :
Code:
ERROR 1227 (42000): Access denied; you need the CREATE USER privilege for this operation
Also, through Webmin web interface, I can only connect to the server, but nothing else is allowed. Whenever I try to access users or any permission related stuff, I get:

Code:
DBI connect failed : Access denied for user ''@'localhost' to database 'mysql'
Does the " user ' ' " thing refers to the anonymous user?? Whys that?

Last edited by lpallard; 03-20-2010 at 09:32 AM.
 
Old 03-20-2010, 09:55 AM   #7
smoker
Senior Member
 
Registered: Oct 2004
Distribution: Fedora Core 4, 12, 13, 14, 15, 17
Posts: 2,279

Rep: Reputation: 249Reputation: 249Reputation: 249
I have no idea what's going on, but I've never heard of an anonymous user in mysql. And the webmin problem is because it's not specifying a user when it connects. You have to set that up.
I always use phpMyAdmin - http://www.phpmyadmin.net/home_page/index.php
 
Old 03-20-2010, 11:10 AM   #8
spampig
Member
 
Registered: Feb 2010
Location: /Earth/UK/England/Hampshire
Distribution: Debian, Ubuntu, CentOS, Slackware
Posts: 262
Blog Entries: 2

Rep: Reputation: 56
I'd was not aware of the anonymous user until I read this a few days ago:

http://www.kitebird.com/articles/ins-sec.html

{About half way down}

I was quite surprised that when I tried:
mysql -u anonymous

I had limited access to the 'information_schema' database with no password. Using the root account and running:
Code:
use mysql
select user from user where password='';
I found a couple of blank 'anonymous' users which I deleted. The worst I every saw was being able to log into the mysql server with full root privileges on a well known email appliance with just:
Code:
mysql
lpallard - I would probably reset the root password and try again - here is how (if you don't already know)
RECOVER FROM LOST ROOT PASSWORD
1. Stop service /etc/init.d/mysql stop
2. Start mysql without password: mysqld_safe --skip-grant-tables & (Don't miss the & off the end)
You'll get output something like: '[1] 6948' to break out of this use [ctrl -z] [enter]
3. connect to mysql as root with no password: mysql -u root
4. set up new root password;
mysql> use mysql;
mysql> update user set password=PASSWORD("new-root-password") where User='root';
update user set password=PASSWORD("sh1verM4d") where User='root';

mysql> flush privileges;
mysql> quit;
5. restart: /etc/init.d/mysql stop; /etc/init.d/mysql start
6. test: mysql -u root -p
 
Old 03-20-2010, 11:45 AM   #9
Blue_Ice
Member
 
Registered: Jul 2006
Location: Belgium
Distribution: Debian, Fedora, CentOS, Windows
Posts: 361

Rep: Reputation: Disabled
Did you change the privileges of the root user? If so, you might have changed a bit too much.
To be secure I always create a second account with SUPER privileges before I change anything on the root account. This way, I cannot lock myself out.

I haven't checked it, but if the privileges of the root account have been changed commands like 'mysqladmin -u root -p password <password>' will not work either.

Something else I noticed was that you tried to use the command 'mysqladmin -u root -p password <password>', but if there is no password on the root account you have to leave out the -p option. Using this option tells mysql that it has to use a password. Normally this is required, unless there is no password for the account. So maybe you should give 'mysqladmin -u root password <password>' a try.

Arjan
 
1 members found this post helpful.
Old 03-20-2010, 11:47 AM   #10
smoker
Senior Member
 
Registered: Oct 2004
Distribution: Fedora Core 4, 12, 13, 14, 15, 17
Posts: 2,279

Rep: Reputation: 249Reputation: 249Reputation: 249
It works fine for me.
I tested it by setting my password to blank using that command and then resetting it using the same command.
 
Old 03-20-2010, 12:07 PM   #11
Blue_Ice
Member
 
Registered: Jul 2006
Location: Belgium
Distribution: Debian, Fedora, CentOS, Windows
Posts: 361

Rep: Reputation: Disabled
Quote:
Originally Posted by smoker View Post
It works fine for me.
I tested it by setting my password to blank using that command and then resetting it using the same command.
And from blank to password? That's what it is about. But as I said, I haven't checked it.

However it doesn't look like an issue with the commands itself, but a privileges related error. So I am more interested about what he did regarding to that. It is a bit weird that the root account doesn't have SUPER privileges, unless someone has changed that.
 
Old 03-20-2010, 09:34 PM   #12
lpallard
Member
 
Registered: Nov 2008
Posts: 985

Original Poster
Rep: Reputation: Disabled
Thumbs up

Thanks to all who replied!

Spampig Yes, I tried all the steps you proposed, but unfortunately that didnt worked. What I had to do was pretty drastic.... I uninstalled the mysql package, and deleted ALL the files that contained the string "mysql" in the "find files & folders" result list... (selected one by one to be sure I was deleting I trusted..) I was fed up and didnt want to mess around with it because you know that gut feeling, this is a bug.. well apparently I was not far, upon reinstallation of the package, I restarted with exactly the same steps as you proposed and it works perfectly! I can access the server as root, supplying my pass, and modify everything just as root should be able to do...

I really think it was either a bug or a corruption in my files... strange, out of the box from the Slack DVD...

If I can help please post.

Thanks!
 
Old 03-20-2010, 09:37 PM   #13
lpallard
Member
 
Registered: Nov 2008
Posts: 985

Original Poster
Rep: Reputation: Disabled
Thanks!

Last edited by lpallard; 03-20-2010 at 09:39 PM.
 
Old 07-17-2017, 12:23 PM   #14
rtawade
LQ Newbie
 
Registered: Jul 2017
Posts: 1

Rep: Reputation: Disabled
Question facing some issues while stopping the mysql

I am facing the same issues as mentioned above..

i tried stopping mysql but it doesnt work.
when i try to execute this command it says such file or directory doesnt exists..
can someone help ?
my defualt password is blank only and when i enter it does ask me to set up a new password but when i tries to set that up it says update command denied.....
 
  


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
Having problems installing MySQL on red hat 9. Cannot find mysql.sock oferu Linux - Newbie 3 05-27-2008 07:13 PM
Problems with MySQL on SuSE: Can't Connect (/var/lib/mysql/mysql.sock) neocookie Linux - Software 8 02-07-2008 11:48 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
DBD::MySQL + MySQL install problems. Elleroth Linux - Software 4 03-24-2006 06:53 AM

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

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