Bug #78285 Connector/Python transforms 'localhost' to '127.0.0.1' - access denied error.
| Submitted: | 31 Aug 2015 9:18 | Modified: | 15 May 2016 10:02 |
|---|---|---|---|
| Reporter: | Shahriyar Rzayev | Email Updates: | |
| Status: | No Feedback | Impact on me: | |
| Category: | Connector / Python | Severity: | S1 (Critical) |
| Version: | 2.0.4 | OS: | CentOS (7) |
| Assigned to: | Assigned Account | CPU Architecture: | Any |
[15 Apr 2016 10:02]
Chiranjeevi Battula
Hello Shahriyar Rzayev, Thank you for the bug report. I could not repeat the issue at my end using Connector / Python 2.1.3 and not seeing any issues to connecting database. And it seems your database user doesn't have sufficient privileges. Please check user privileges. Manual for user privileges: http://dev.mysql.com/doc/refman/5.7/en/adding-users.html Thanks, Chiranjeevi.
[16 May 2016 1:00]
Bugs System
No feedback was provided for this bug for over a month, so it is being suspended automatically. If you are able to provide the information that was originally requested, please do so and change the status of the bug back to "Open".
Portions of this website are copyright © 2001, 2002 The PHP Group
Page generated in 0.051 sec. using MySQL 8.4.7-u6-cloud
Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the
respective copyright holders.
It is not reviewed in advance
by Oracle and does not necessarily represent the opinion of
Oracle or any other party.
Description: So i have in MySQL 'tst'@'localhost' user: [root@centos-base ~]# mysql -u tst -p --host='localhost' Enter password: Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 49 Server version: 5.5.44-MariaDB-log MariaDB Server Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]> \q [root@centos-base ~]# mysql -u tst -p --host='127.0.0.1' Enter password: ERROR 1045 (28000): Access denied for user 'tst'@'127.0.0.1' (using password: YES) When i used it in a script: import mysql.connector from mysql.connector import errorcode def check_mysql_flush_log_user(): # Creating test Database and user for flushing binary logs. # Connection Settings config = { 'user': 'tst', 'password': '12345', 'host': 'localhost', # 'database': 'mysql', 'raise_on_warnings': True, } # Open connection try: cnx = mysql.connector.connect(**config) cursor = cnx.cursor() query1 = "create database if not exists bck" print("Creating Test User (test_backup)+-+-+-+-+-+-+-+-+-++-+-+-+-+-OK") time.sleep(2) print("Creating Test Database (bck)+-+-+-+-+-+-+-+-+-++-+-+-+-+-+-+-OK") cursor.execute(query1) cursor.close() cnx.close() return True except mysql.connector.Error as err: if err.errno == errorcode.ER_ACCESS_DENIED_ERROR: #print("Something is wrong with your user name or password!!!") print(err) return False elif err.errno == errorcode.ER_BAD_DB_ERROR: print("Database does not exists") return False elif err.errno == errorcode.ER_DB_CREATE_EXISTS: print("Database Already exists") return True else: print(err) return False check_mysql_flush_log_user() [root@centos-base ~]# /opt/Python-3.3.2/bin/python3 test_connection.py 1045 (28000): Access denied for user 'tst'@'127.0.0.1' (using password: YES) It is using '127.0.0.1' even if explicitly specifying 'localhost'. How to repeat: 1. create user 'tst'@'localhost' identified by '12345'; grant all on *.* to 'tst'@'localhost'; 2. Try to connect to MySQL using Python code above. using 'host':'localhost' Suggested fix: Workaround is creating same user with '127.0.0.1'.