Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Trying to find a way in by going through checklist of possible reasons I am locked out of mysql and one, I read, is to determine if I have grant tables.

-bash-4.1# cd /var
-bash-4.1# ls
cache  empty  lib    lock  mail  opt       run    tmp  yp
db     games  local  log   nis   preserve  spool  www
-bash-4.1# ls db

Apparently I am supposed to see a file named user.MYD in the db directory. I don't even remember if I created a db after reinstall but I see 'db' there so that must be it(?)

Is there a way I can drop the database and recreate one without access in?

share|improve this question

If there's anything, it should reside in /var/lib/mysql.

Anyway, you could start mysql in safe mode that disables authentication, e.g

# /etc/init.d/mysql stop # depend on your distribution
# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &

Now change the password:

# mysql -u root mysql
mysql> UPDATE user SET Password=PASSWORD('newpassword') where USER='root';
mysql> quit

Afterwards, kill mysqld and restart the service

share|improve this answer
Why do you need to start in safe mode, for security ? – freja Nov 29 '12 at 9:40
@freja that disables password auth – warl0ck Nov 29 '12 at 9:41
Ok thanks, anyway weirdly I was able to get in and change username and password. – freja Nov 29 '12 at 12:34
@freja oh, what you mean by locked out then – warl0ck Nov 29 '12 at 12:41
it is a mystery to me. I was completely locked out and then all of a sudden I could get in as root where before couldn't. No syntax error. – freja Nov 29 '12 at 12:43

Your Answer


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.