0

I've got an issue with my code. For some reason upon trying to connect my Python code with the MySQL database

I get the following error :

File "C:\Users\Sofia\AppData\Local\Programs\Python\Python36-32\lib\site-packages\mysql\connector\connection.py",
line 213, in _auth_switch_request
raise errors.get_exception(packet) mysql.connector.errors.ProgrammingError: 1045 (28000): Access denied
for user 'root'@'localhost' (using password: YES)

I've tried to add a port into MySQL and to grant access to my user however that didn't work, I'd really appreciate if you could give me a step by step instruction on how to fix this issue. Thanks!

Ali
  • 2,174
  • 2
  • 25
  • 39
  • Is the server a remote one? By default, the `root` user will only allow connections from the localhost, regardless of correct credentials. As a sidenote (and security recommendation), using the root user for anything not related to server administration is a **huge** no-no as it opens your server up with no limits should you ever become compromised – Javier Larroulet Dec 12 '18 at 01:26
  • 3
    Possible duplicate of [MySQL ERROR 1045 (28000): Access denied for user 'bill'@'localhost' (using password: YES)](https://stackoverflow.com/questions/10299148/mysql-error-1045-28000-access-denied-for-user-billlocalhost-using-passw) – Javier Larroulet Dec 12 '18 at 01:28
  • @JavierLarroulet, are you talking about the _OS_ `root` user? MySQL has its own `root` user that is unrelated to the OS `root` user. Be careful when talking about OS-level defaults; they're not universal. – Chris Dec 12 '18 at 01:31
  • @Chris I'm talking about `Access denied for user 'root'@'localhost` ... The MySQL root user shouldn't be used for an application any more than the OS root user should be used to perform non-administrative taks on the OS level. Ever. – Javier Larroulet Dec 12 '18 at 01:34
  • @JavierLarroulet, I'm not arguing that MySQL's `root` user should be used generally. I'm just pointing out that it's separate from the OS-level `root` user, and that your language about server administration makes it look like you're talking about the latter. And although it's not a good idea to use the MySQL `root` user when it's not required, this user _doesn't_ "open up your server with no limits". It gives full admin access to _MySQL_, which isn't something to play with, but it's a lot less than full admin access to the OS. – Chris Dec 12 '18 at 01:43
  • Idiomatic barrier maybe... Replace "server administration" with "database administration" ;) and yes, a compromised root DB user is as dangerous as a compromised root Linux user... Not for the same reasons (as the stuff you could get done varies) but still, depending on what lives on the database and the Linux box, under some circumstances a compromised DB user may be an entry vector for a lot of damage (data theft, data loss, etc) – Javier Larroulet Dec 12 '18 at 01:54

0 Answers0