LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
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 05-16-2010, 05:54 PM   #1
alunduil
Member
 
Registered: Feb 2005
Location: San Antonio, TX
Distribution: Gentoo
Posts: 684

Rep: Reputation: 62
Why is mysql automatically logging me in without .my.cnf or my.cnf sections?


I've checked and double checked that there is no user and password directive in /etc/my.cnf and ~/.my.cnf but it seems that every time I issue mysql it will drop me into the command line without prompting for a password or giving any pause. Of course, the only table I have access to when doing this is information_schema with read only on most of it and no access on the rest, but I was just wondering where else an auto-login style authentication could be coming from.

Thanks in advance,

Alunduil
 
Old 05-16-2010, 06:05 PM   #2
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Uh - maybe from not having defined a password for all users (most especially "root")?

Strong recommendation:
Quote:
mysql -uroot mysql
select User,Host,Password from user;
<= Create passwords, or delete, all users with "blank" passwords!
 
Old 05-16-2010, 06:42 PM   #3
alunduil
Member
 
Registered: Feb 2005
Location: San Antonio, TX
Distribution: Gentoo
Posts: 684

Original Poster
Rep: Reputation: 62
All users have a password set and just for good measure I removed some users that I don't use any longer. Any other ideas?

Regards,

Alunduil
 
Old 05-16-2010, 11:35 PM   #4
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Quote:
Q: Any other ideas?
A: Yes.
Please run this command, and cut/paste the results ("X" out any passwords from the post):

Quote:
mysql -uroot -pYOUR_ROOT_PASSWORD mysql
select User,Host,Password from user;
 
Old 05-18-2010, 11:33 PM   #5
alunduil
Member
 
Registered: Feb 2005
Location: San Antonio, TX
Distribution: Gentoo
Posts: 684

Original Poster
Rep: Reputation: 62
Here you go. Sorry it took so long it's been a hectic week.

Code:
alunduil@giskard ~ $ mysql -uroot -p mysql
Enter password: 
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1871
Server version: 5.0.90-log Gentoo Linux mysql-5.0.90-r2

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> select User,Host,Password from user;
+-----------+-----------+-------------------------------------------+
| User      | Host      | Password                                  |
+-----------+-----------+-------------------------------------------+
| root      | localhost | *XXXXX | 
| root      | giskard   | *XXXXX | 
| snort     | 127.0.0.1 | *XXXXX | 
| snort     | localhost | *XXXXX | 
| wordpress | localhost | *XXXXX | 
+-----------+-----------+-------------------------------------------+
5 rows in set (0.00 sec)

mysql>
Regards,

Alunduil
 
Old 05-18-2010, 11:56 PM   #6
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Hi -

I'm confused

It looks like it *did* prompt you for a password (it says "Enter Password:").

Do you think maybe you somehow inadvertantly made "<Enter>" a valid password? What happens if you *change* the root password?

For whatever it's worth, here's how I usually go into the MySQL monitor:
Quote:
$ mysql -uroot -pROOT_PASSWORD mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1278
Server version: 5.0.77 Source distribution
Note that there's *no space* between "-u" and "root", or "-p" and the password.

'Hope that helps .. PSM
 
Old 05-19-2010, 12:01 AM   #7
alunduil
Member
 
Registered: Feb 2005
Location: San Antonio, TX
Distribution: Gentoo
Posts: 684

Original Poster
Rep: Reputation: 62
Yes, but what I'm saying is as my user I'm able to issue the command: mysql (no options) and it will drop me at a prompt. That's the issue. When I specify a user and tell mysql (through the -p switch) to prompt me for the password of course it's going to.

I do understand the command you provided in your last post and the -uroot can have a space. You are able to pass -u root and mysql will parse it correctly. The same does not go for the password because if -p is found alone mysql prompts for the password (making it so shoulder surfers don't get what they are there for).

I was thinking it might be a stray .my.cnf that was getting pulled in from my environment but I don't see anything like that.

Regards,

Alunduil
 
Old 05-19-2010, 12:37 AM   #8
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Hi -

Actually, my understanding of the "-p" options was primarily to allow you to enter it in-line (and prevent wasting time responding to some silly "Enter Password:" prompt).

Neither here nor there:
a) if you entered "-p" with a valid password, you should get in (without being challenged, and without seeing an "Enter Password" prompt).

b) I completely understand that your problem is that you don't seem to need a password in the first place (despite the fact that all users - including root - appear to have valid passwords).

I'm still suggesting that maybe the root password somehow got set to "\n". Couldn't hurt to change it...

You've absolutely confirmed that no MySql users have a null password - thank you.

And you're absolutely correct: now that we seem to have ruled out just about everything else, some ".my.cnf" file somewhere in the environment is just about the only thing left that makes any sense.

Q: have you tried all of the following commands:
Quote:
ls -la /root/.my.cnf

ls -la ~/.my.cnf

find / -name .my.cnf -print 2>/devnull

find / -name my.cnf -print 2>/devnull
Please keep us posted what you find - and good luck!

Last edited by paulsm4; 05-19-2010 at 12:39 AM.
 
Old 05-19-2010, 03:07 AM   #9
Blue_Ice
Member
 
Registered: Jul 2006
Location: Belgium
Distribution: Debian, Fedora, CentOS, Windows
Posts: 361

Rep: Reputation: Disabled
Quote:
Originally Posted by alunduil View Post
Yes, but what I'm saying is as my user I'm able to issue the command: mysql (no options) and it will drop me at a prompt. That's the issue. When I specify a user and tell mysql (through the -p switch) to prompt me for the password of course it's going to.
That's default behaviour. As you will see when you test it, you will not be able to see your databases, nor will you be able to make changes.

Edit: This will not be possible from any other system, then localhost.

Last edited by Blue_Ice; 05-19-2010 at 03:11 AM.
 
Old 05-19-2010, 11:34 AM   #10
alunduil
Member
 
Registered: Feb 2005
Location: San Antonio, TX
Distribution: Gentoo
Posts: 684

Original Poster
Rep: Reputation: 62
Sorry about my earlier frustrations. It seems after removing the extra users that you pointed out from your first post and then finally restarting mysql provided the desired effect. If this issue surfaces again I hope to get a better answer.

Thanks for all the patience and help everyone.

Regards,

Alunduil
 
Old 05-19-2010, 11:36 AM   #11
alunduil
Member
 
Registered: Feb 2005
Location: San Antonio, TX
Distribution: Gentoo
Posts: 684

Original Poster
Rep: Reputation: 62
Also, Blue_Ice, here's the default behaviour on two separate boxes:

Code:
alunduil@dornick ~ $ mysql
ERROR 1045 (28000): Access denied for user 'alunduil'@'localhost' (using password: NO)
Code:
alunduil@giskard ~ $ mysql 
ERROR 1045 (28000): Access denied for user 'alunduil'@'localhost' (using password: NO)
Regards,

Alunduil
 
Old 05-19-2010, 11:52 AM   #12
Blue_Ice
Member
 
Registered: Jul 2006
Location: Belgium
Distribution: Debian, Fedora, CentOS, Windows
Posts: 361

Rep: Reputation: Disabled
Quote:
Originally Posted by alunduil View Post
Also, Blue_Ice, here's the default behaviour on two separate boxes:

Code:
alunduil@dornick ~ $ mysql
ERROR 1045 (28000): Access denied for user 'alunduil'@'localhost' (using password: NO)
Code:
alunduil@giskard ~ $ mysql 
ERROR 1045 (28000): Access denied for user 'alunduil'@'localhost' (using password: NO)
Regards,

Alunduil
Sorry, forgot to mention that MySQL tries to use the linux user you logged in without password. I am not sure if MySQL tries to log in with an empty account if that doesn't work. Still default behavior as you can see in the response you get from the server.
 
  


Reply

Tags
mycnf, mysql



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
mySQL my.cnf question.. DropHit Linux - Software 2 04-15-2010 02:16 PM
Missing my.cnf after installing mysql 5.1.35 jdnow09 Linux - General 3 06-18-2009 11:10 PM
MySQL startup process and my.cnf lord-fu *BSD 4 07-11-2007 07:44 AM
how to config the mysql my.cnf? treotan Linux - General 1 09-14-2005 11:05 AM
MySQL server & my.cnf hct224 Linux - Newbie 0 04-02-2004 01:03 PM

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

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