mysql login after install [ERROR 1045 (28000): Acc

2019-08-30 09:45发布

问题:

Using a mac w/ mountain lion, I just installed mysql. I am now trying to login using the following command

mysql -u mike -p

but get the following error:

ERROR 1045 (28000): Access denied for user 'mike'@'localhost' (using password: YES)

I have referenced the following SO question & answer: MySQL ERROR 1045 (28000): Access denied for user 'bill'@'localhost' (using password: YES)

based on all those answers I need to create a new local user inside mysql command line, but how do I do this if I can't get access to the mysql> (command line)?

回答1:

By default, the root user has no password in MySQL (unless you set a root password in mysql during the install). Try logging in like this:

mysql -u root

Note the exclusion of the -p argument.



回答2:

Try using:

$ mysql -u root -e "CREATE USER 'mike'@'localhost' IDENTIFIED BY PASSWORD 'secret';";

And then see Grant Syntax for setting the appropriate priviledges.