1045, "Access denied for user 'username'@'NOT-local' (using password: YES)"

spen123

I have a user in mySQL database like this

enter image description here

And I am trying to login to mySQL on serverA from server B, in python, here is what I am currently doing,

db  = MySQLdb.connect(host='IP-address-server-A', user='username', passwd='my-password', db='my-database')

And I am getting this error

(1045, "Access denied for user 'username'@'serverB' (using password: YES)")

What is going on, and why can't I connect?

Thanks for the help

Drew

show logins to the server (note that % means anyhost or wildcard)

select user,host from mysql.user;

+-----------+------------+
| user      | host       |
+-----------+------------+
| ajax_guy  | %          |
| joe7      | %          |
| joe8      | %          |
+-----------+------------+

show what grants exist for a certain user.

show grants for 'ajax_guy'@'%';

+----------------------------------------------------------------------
| Grants for ajax_guy@%                                              
+----------------------------------------------------------------------
| GRANT USAGE ON *.* TO 'ajax_guy'@'%' IDENTIFIED BY PASSWORD ...
| GRANT ALL PRIVILEGES ON `ajax_stuff`.* TO 'ajax_guy'@'%'           
| GRANT ALL PRIVILEGES ON `ajax_stuff`.`ajax_stuff` TO 'ajax_guy'@'%'
+----------------------------------------------------------------------

How to grant access to a certain db to a certain login. Below we are granting all rights to the user to the so_gibberish database.

grant ALL on so_gibberish.* to 'ajax_guy'@'%';

Look at grants in effect now for that login

+----------------------------------------------------------------------
| Grants for ajax_guy@%                                              
+----------------------------------------------------------------------
| GRANT USAGE ON *.* TO 'ajax_guy'@'%' IDENTIFIED BY PASSWORD ...
| GRANT ALL PRIVILEGES ON `ajax_stuff`.* TO 'ajax_guy'@'%'           
| GRANT ALL PRIVILEGES ON `so_gibberish`.* TO 'ajax_guy'@'%'         
| GRANT ALL PRIVILEGES ON `ajax_stuff`.`ajax_stuff` TO 'ajax_guy'@'%'
+----------------------------------------------------------------------

Create a new login drew_saturday with a password friday987. He has all privileges on database so_gibberish and can login from any host (%)

grant ALL on so_gibberish.* to 'drew_saturday'@'%' IDENTIFIED BY 'friday987';

select user,host,password from mysql.user where user='drew_saturday';

+---------------+------+-------------------------------------------+
| user          | host | password                                  |
+---------------+------+-------------------------------------------+
| drew_saturday | %    | *4600ED0F377308959665877BD327D4788DC2071F |
+---------------+------+-------------------------------------------+

That password above is the hashed password by the way.

Note: for MySQL 5.7 the command above would be:

select user,host,authentication_string from mysql.user where user='drew_saturday';

Mysql manual page on Grant. Do not grant excessive rights to users using grant ALL on *. .... That would be for all database in the system. Just read the manual and less is more.

Sometimes, admins want to grant access to just a handful of tables in a database (not all tables in it) to a login. The manual is a must read on this.


And one last thing. 'drew_saturday'@'%' is a different login than 'drew_saturday'@'NOT-local' (borrowing from your title). They are different logins with different rights. That is the point of the first thing I wrote way up there.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

phpMyAdmin MySQL error # 1045

From Dev

phpmyadmin stopped woking (1045)

From Dev

Laravel 5 migration error 1045

From Dev

#1045 Cannot log in to the MySQL server

From Dev

000 webhost #1045 - Access denied for user

From Dev

ERROR 1045 (28000): Access denied for user 'root'@'%'

From Dev

phpmyadmin in WAMP error #1045 - Need to reset password

From Dev

MySQL ERROR 1045 in bash script - access denied

From Dev

PHP MySql (1045) Access Denied For User

From Dev

Python MySQLdb - Error 1045: Access denied for user

From Dev

ERROR 1045 (28000) access denied cloudSQL

From Dev

mysqldump: Got error: 1045 Access denied

From Dev

#1045 Cannot log in to the MySQL server in wamp

From Dev

WAMP ERROR - #1045 Cannot log in to the MySQL server

From Dev

Installing phpmyadmin package ERROR 1045 (28000)

From Dev

Python MySQLdb - Error 1045: Access denied for user

From Dev

PDOException: SQLSTATE[28000] [1045] Access denied for user

From Dev

phpmyadmin in WAMP error #1045 - Need to reset password

From Dev

ERROR 1045 (28000) access denied cloudSQL

From Dev

ERROR 1045 (28000): Access denied for user 'root'@'%'

From Dev

Django - MySQL: 1045 Access Denied for 'user'@'localhost'

From Dev

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

From Dev

OperationalError: (1045, "Access denied for user 'root'@'localhost' (using password: NO)")

From Dev

ERROR 1045 (28000): Access denied for user 'username'@'%' (using password: YES)

From Dev

Laravel: SQLSTATE[28000] [1045] Access denied for user 'homestead'@'localhost'

From Dev

OperationalError: (1045, "Access denied for user 'root'@'localhost' (using password: YES)")

From Dev

build-impl.xml:1045: Deployment error: Starting of Tomcat failed

From Dev

ERROR 1045: Transferring SQL database from one server to another

From Dev

ERROR 1045 (28000): Access denied for user 'username'@'%' (using password: YES)

Related Related

  1. 1

    phpMyAdmin MySQL error # 1045

  2. 2

    phpmyadmin stopped woking (1045)

  3. 3

    Laravel 5 migration error 1045

  4. 4

    #1045 Cannot log in to the MySQL server

  5. 5

    000 webhost #1045 - Access denied for user

  6. 6

    ERROR 1045 (28000): Access denied for user 'root'@'%'

  7. 7

    phpmyadmin in WAMP error #1045 - Need to reset password

  8. 8

    MySQL ERROR 1045 in bash script - access denied

  9. 9

    PHP MySql (1045) Access Denied For User

  10. 10

    Python MySQLdb - Error 1045: Access denied for user

  11. 11

    ERROR 1045 (28000) access denied cloudSQL

  12. 12

    mysqldump: Got error: 1045 Access denied

  13. 13

    #1045 Cannot log in to the MySQL server in wamp

  14. 14

    WAMP ERROR - #1045 Cannot log in to the MySQL server

  15. 15

    Installing phpmyadmin package ERROR 1045 (28000)

  16. 16

    Python MySQLdb - Error 1045: Access denied for user

  17. 17

    PDOException: SQLSTATE[28000] [1045] Access denied for user

  18. 18

    phpmyadmin in WAMP error #1045 - Need to reset password

  19. 19

    ERROR 1045 (28000) access denied cloudSQL

  20. 20

    ERROR 1045 (28000): Access denied for user 'root'@'%'

  21. 21

    Django - MySQL: 1045 Access Denied for 'user'@'localhost'

  22. 22

    ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

  23. 23

    OperationalError: (1045, "Access denied for user 'root'@'localhost' (using password: NO)")

  24. 24

    ERROR 1045 (28000): Access denied for user 'username'@'%' (using password: YES)

  25. 25

    Laravel: SQLSTATE[28000] [1045] Access denied for user 'homestead'@'localhost'

  26. 26

    OperationalError: (1045, "Access denied for user 'root'@'localhost' (using password: YES)")

  27. 27

    build-impl.xml:1045: Deployment error: Starting of Tomcat failed

  28. 28

    ERROR 1045: Transferring SQL database from one server to another

  29. 29

    ERROR 1045 (28000): Access denied for user 'username'@'%' (using password: YES)

HotTag

Archive