Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Does a root user without a password constitute a security breach if my MySQL server only accepts connections from localhost?

I'm aware that the common wisdom says the root user should be protected by a password, but what are the implications of leaving it blank? I'm not concerned about Linux users other than my own connecting to MySQL and I am not planning to allow network access to the database.

Edit: What makes MySQL that different from SQLite, which isn't password protected? What kind of deployment scenarios are we talking about? If an attacker gains access to the server, what prevents the attacker from simply resetting the password?

Please keep in mind that I'm not trying to advocate anything here, I just want people's educated input on the matter.

share|improve this question
1  
What you plan is irrelevant to an attacker, they have different plans - follow @womble's advice. The reason it is common wisdom is because it is a very good idea :-) –  Rory Alsop Jul 5 '12 at 11:59
    
Of course it's OK. When the hackers gain entry into your machine through some other means they will never think to try the default settings to access the databases, so it's perfectly safe to leave them as they are. –  John Gardeniers Jul 7 '12 at 11:30
1  
@JohnGardeniers: The problem with sarcasm is that the people who need to heed the advice the most don't recognise it... –  womble Jul 7 '12 at 17:23

2 Answers 2

Yes, I'd consider it a fairly fundamental security vulnerability. Let me illustrate that by way of a story.

Long, long ago, in my younger and less knowledgeable days, I setup a server for internal testing of various bits and pieces I was testing out. It sat on my desk, unconnected to any network (this was a long time ago, before everything had to be on a network to be able to do anything). Whilst I was out of the office, someone else had need of a machine, and took my testing machine (I didn't mind; I was using the machine on the basis that it could be taken for other things if necessary). Since it was already running the OS that was needed, they just plugged it in to the network, and installed what they needed to.

The problem was, I'd setup all sorts of test accounts on that box, with easy to guess passwords (like the ever-useful test). Even that long ago, there were no shortage of miscreants who would have nothing better to do than password-guess accounts. It didn't take very long for them to find this machine, guess a password, and have their nefarious way with it.

The moral of the story? Requirements change. Even though you don't expect to do so now, there is a reasonable chance that over the life of the machine it's role will change -- the most likely outcome, I would expect, would be that other users will have access to the machine (either legitimately, or via an application-level exploit). The chances that you'll remember to set a MySQL root password when necessary are... slim, at best.

My recommendation would be to take the 10 seconds it'll take to set a MySQL root password and drop it into ~root/.my.cnf. The once-off time cost is far less than the cost of compromise times the probability of compromise.

share|improve this answer

Exactly. You are not concerned about Linux users other than your own connecting to MySQL, and you will never be until they drop everything in MySQL.

Now, seriously, you should add a password. Consider that if someone tries to get into your server, they will have to compromise an user password from the server, and then also compromise the root password from MySQL. If you have not got a MySQL password, then it's easier to hack it.

Plus, no program is free of bugs. Just think that, if a bug in MySQL treats every connection as "local", you are going to have big problems.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.