Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 A combination of Python and MySql
#1
Hello,,

I am not sure if I have started this topic in the right place, if not, please move it.
I have a problem with the connection between Python and the MySQL database. When debugging the code
import mysql.connector

con = mysql.connector.connect(user='admin',password='admin123',host='127.0.0.1',port='3306',database='admin')
Traceback (most recent call last):
  File "C:\Users\Asus\Desktop\1.py", line 6, in <module>
    db = pymysql.connect("127.0.0.1","admin","admin123","admin" )
  File "D:\Python33\lib\site-packages\pymysql\__init__.py", line 90, in Connect
    return Connection(*args, **kwargs)
  File "D:\Python33\lib\site-packages\pymysql\connections.py", line 699, in __init__
    self.connect()
  File "D:\Python33\lib\site-packages\pymysql\connections.py", line 936, in connect
    self._request_authentication()
  File "D:\Python33\lib\site-packages\pymysql\connections.py", line 1156, in _request_authentication
    auth_packet = self._read_packet()
  File "D:\Python33\lib\site-packages\pymysql\connections.py", line 1018, in _read_packet
    packet.check_error()
  File "D:\Python33\lib\site-packages\pymysql\connections.py", line 384, in check_error
    err.raise_mysql_exception(self._data)
  File "D:\Python33\lib\site-packages\pymysql\err.py", line 107, in raise_mysql_exception
    raise errorclass(errno, errval)
pymysql.err.OperationalError: (1045, "Access denied for user 'admin'@'localhost' (using password: YES)")
I also tried importing pymysql and the effect was also the same

import pymysql

db = pymysql.connect("127.0.0.1","admin","admin123","admin" )

cursor = db.cursor()
Traceback (most recent call last):
  File "C:\Users\Asus\Desktop\1.py", line 5, in <module>
    db = pymysql.connect("127.0.0.1","admin","admin123","admin" )
  File "D:\Python33\lib\site-packages\pymysql\__init__.py", line 90, in Connect
    return Connection(*args, **kwargs)
  File "D:\Python33\lib\site-packages\pymysql\connections.py", line 699, in __init__
    self.connect()
  File "D:\Python33\lib\site-packages\pymysql\connections.py", line 936, in connect
    self._request_authentication()
  File "D:\Python33\lib\site-packages\pymysql\connections.py", line 1156, in _request_authentication
    auth_packet = self._read_packet()
  File "D:\Python33\lib\site-packages\pymysql\connections.py", line 1018, in _read_packet
    packet.check_error()
  File "D:\Python33\lib\site-packages\pymysql\connections.py", line 384, in check_error
    err.raise_mysql_exception(self._data)
  File "D:\Python33\lib\site-packages\pymysql\err.py", line 107, in raise_mysql_exception
    raise errorclass(errno, errval)
pymysql.err.OperationalError: (1045, "Access denied for user 'admin'@'localhost' (using password: YES)")
The password and login match. Are you able to tell me something in the topic, I'm fighting the second day and I do not know what the problem may be? I will also swear that I am a layperson when it comes to python. I'm just learning it.
If this is the essence of information, then the server I have placed on a virtual machine on which Debian9 is installed, while python 3 works on windows7.
Quote
#2
The error message says that your user doesn't have permission to access the database. You will either have to sign in with a user who does have permission, or get your user added the database's group, with read permission, and write permission if you want to change the database.
Quote
#3
Photo 
in php my admin has permission granted to admin, ALL PRIVILEGES permission, User account 'admin' @ 'localhost'

Can you throw sreens here?
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Python MySQL ogautier 0 240 Sep-03-2020, 03:54 PM
Last Post: ogautier
  Insert into mysql through python LaKhWaN 0 142 Aug-26-2020, 04:54 AM
Last Post: LaKhWaN
  Python mysql query help please tduckman 4 594 Mar-13-2020, 03:42 PM
Last Post: Marbelous
  Checking if the combination of two keys is in a dictionary? mrsenorchuck 6 683 Dec-04-2019, 10:35 AM
Last Post: mrsenorchuck
  how to get all the possible permutation and combination of a sentence in python sodmzs 1 887 Jun-13-2019, 07:02 AM
Last Post: perfringo
  while + if + elif + else combination ClassicalSoul 1 616 Mar-27-2019, 03:54 PM
Last Post: ichabod801
  Is there a datepicker which can be used in combination with the python library urwid? AFoeee 5 2,047 Nov-18-2018, 08:54 PM
Last Post: AFoeee
  mysql db connection using python sunstar20 13 4,714 Aug-04-2018, 09:08 AM
Last Post: vishalhule
  ssh + mysql connection python 3.4.3 desudesu 9 7,927 May-25-2017, 03:19 PM
Last Post: desudesu
  Python 3 mysql export to csv elliott0184 3 11,022 Feb-23-2017, 03:18 PM
Last Post: joe_anonimist

Forum Jump:


Users browsing this thread: 1 Guest(s)