1

I just installed mysql in lion and am now trying to set the root password. I can get into mysql no problem by simply typing:

mysql

But when I try to get in as the root user which should let me in without issue as I have not set the root password yet by typing I get denied:

mysql -u root 

Error:

connect to server at 'localhost' failed error: 'Access denied for user 'root'@'localhost' (using password: NO)'

I have done plenty of searches on this issue but none have solved the problem. I am just denied no matter what as if there is a password set... I did have an installation of XAMPP installed earlier that I just deleted where I set the root password but I can't imagine there would be any conflict between the two installations... expecially since the XAMPP version has been deleted anyway. I have tried default creds like -u root -p root.

Why is this so difficult to do. I'd like to get on with my training. WTF

EZDC
  • 682
  • 1
  • 17
  • 33
  • Have you tried `mysql -u root -p` and then hitting Enter? – galymzhan Jul 26 '12 at 04:19
  • yes. It prompts me for a password. I hit enter again as there shouldn't be a pass set but I get the same error. There seems to be a pass set but I don't know what it is...? – EZDC Jul 26 '12 at 04:40
  • I had a similar issue in linux but not in OSX Lion, so maybe this will help: first start the service `mysqld` like `service mysqld start`, then try running `mysql_secure_installation`. It's supposed to setup the users database and other stuff, so you have a database to login into. – xiankai Jul 26 '12 at 04:41
  • I am getting this: -bash: service: command not found when typing: service mysqld start ....? – EZDC Jul 26 '12 at 04:53
  • Ok I ran the secure installation and I get this error: In order to log into MySQL to secure it, we'll need the current password for the root user. If you've just installed MySQL, and you haven't set the root password yet, the password will be blank, so you should just press enter here. When I press enter I get the same access denied. should I remove mysql and try to reinstall or is there some sort of file that holds the credentials outside of mysql? – EZDC Jul 26 '12 at 05:16
  • Worth a shot to reinstall, I don't think there even is a database of users set up at this point. – xiankai Jul 26 '12 at 05:31
  • Yea just reinstalled same problem. There must be some sort of password set by the system or a file that was there previously. I know nothing about all this so I can't even speak intelligently about it. Anyone have an idea of what could be happening here? – EZDC Jul 26 '12 at 05:49
  • A step I forgot to mention: have you installed `mysql-server` as well? Maybe after that you can start the `mysqld` service? – xiankai Jul 26 '12 at 05:53
  • The same way you installed `mysql`? Using either `apt-get install mysql-server` or `yum install mysql-server` I suppose. – xiankai Jul 26 '12 at 06:05
  • wow... I restarted the computer, turned off and on mysql and boom it worked...? strange... thanks for the help guys – EZDC Jul 26 '12 at 06:18

1 Answers1

1

As you mention that mysql -u root -p and mysql_secure_installation throw same error.So try to install mysql-server as

apt-get install mysql-server
nKandel
  • 2,543
  • 1
  • 29
  • 47