简体   繁体   中英

MySQL Access denied error

I am trying to install mySQL on a Mac OS 10.8 and set up a user account. NOTE I am a abs beginner when it comes to using the command line in Terminal window.

I used these instructions to install: http://www.macminivault.com/mysql-mountain-lion/

I set my own password for all users here:

 GRANT ALL ON *.* TO 'root'@'localhost' IDENTIFIED BY 'mypass' WITH GRANT OPTION;
quit

Every time i try to execute mySQL as a root user on the command line i get this:

Ciarans-MacBook-Pro:~ callanmooneys$ mysql -u root
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

I read around on the net and tried various things including tried this to change password:

mysqladmin -u root -pyourcurrentmysqlrootpassword password yournewmysqlrootpassword,
it returns -> 
    -> USE mysql
    -> 

If i simply type 'mysql' and launch the mySQL monitor then try to crete a user account:

mysql> USE mysql
ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'mysql'
mysql> 

Also tried answers on forum: access is denied for user 'root'@localhost mysql error 1045 returned 'root@127.0.0.1 command not found

And MySQL - ERROR 1045 - Access denied :

Ciarans-MacBook-Pro:~ callanmooneys$ mysqld_safe --skip-grant-tables
131105 21:44:41 mysqld_safe Logging to '/usr/local/mysql/data/Ciarans-MacBook-Pro.local.err'.
131105 21:44:41 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
/usr/local/mysql/bin/mysqld_safe: line 129: /usr/local/mysql/data/Ciarans-MacBook-Pro.local.err: Permission denied
/usr/local/mysql/bin/mysqld_safe: line 166: /usr/local/mysql/data/Ciarans-MacBook-Pro.local.err: Permission denied
131105 21:44:41 mysqld_safe mysqld from pid file /usr/local/mysql/data/Ciarans-MacBook-Pro.local.pid ended
/usr/local/mysql/bin/mysqld_safe: line 129: /usr/local/mysql/data/Ciarans-MacBook-Pro.local.err: Permission denied
Ciarans-MacBook-Pro:~ callanmooneys$ mysql -u root
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
Ciarans-MacBook-Pro:~ callanmooneys$

Feedback appreciated.

Bit confusing but deleted mySQL and all associated files , re installed, set root password, logged on as mysql -u root -p (password) And it worked fine.

There is allot of resources on the net which can be confusing, for anyone experiencing similar problems i recommend using the official site here:

http://dev.mysql.com/doc/refman/5.1/en/access-denied.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM