Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I login as root on MySQL on OS X?

Tags:

People also ask

How do I log into MySQL with a root user?

Enter mysql.exe -uroot -p , and MySQL will launch using the root user. MySQL will prompt you for your password. Enter the password from the user account you specified with the –u tag, and you'll connect to the MySQL server.

How do I become a root user in OSX?

Click Open Directory Utility. in the Directory Utility window, then enter an administrator name and password. From the menu bar in Directory Utility: Choose Edit > Enable Root User, then enter the password that you want to use for the root user.


I've just set up MySQL on my computer (OS X 10.7), and it seems to be working, judging by the "mysqld" in the activity monitor and the new icon in my System Preferences.

However I'm having trouble doing anything with MySQL, as I need to login at least as the root user, but it doesn't let me. So let's run through what I've been doing and what error messages I'm getting:

Firstly, I start up MySQL via the "mysql" unix executable file. This seems to work, as my entries are now preceded with

 mysql> 

Also, I can type

 help;

and I get MySQL's help list. So then I go to do something, like create a database:

 CREATE DATABASE books;

but I get the following error:

 ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'books'

So then I figure I need to login, and that logging in as the root user should be enough. I enter the following:

 mysql -u root -p;

But I get the 1064 error saying my syntax is wrong. I've had a look around through a number of websites, and this never seems to be a problematic step. Any clues on what's going wrong for me?