Python Mysqldb Error 1045
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this operationalerror 1045 access denied for user root localhost using password yes site About Us Learn more about Stack Overflow the company Business Learn more mysql_setpermission about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x error 1045 (28000) access denied for user (using password: yes) Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Python MySQL python mysqldb example OperationalError: 1045, "Access denied for user root@'localhost' up vote 1 down vote favorite 1 I was trying to access the database from my python program by: db = mysql.connect(host = 'localhost', user = 'Max', passwd = 'maxkim', db = 'TESTDB') cursor = db.cursor() But, I get an error message in the first line of code. OperationalError: (1045, "Access denied for user 'Max'@'localhost' (using password:
Error 1045 (28000): Access Denied For User 'root'@'localhost' (using Password: No)
YES)") To remedy the situation, I did the following: $ mysql -u Max-p Enter password: maxkim mysql> create database TESTDB; mysql> grant usage on *.* to Max@localhost identified by ‘maxkim’; mysql> grant all privileges on TESTDB.* to Max@localhost ; mysql> exit If I have granted all access to the the database for the user "Max" (me), why can't I still connect in python? python mysql share|improve this question asked Jul 2 '13 at 12:22 Max Kim 4184616 add a comment| 2 Answers 2 active oldest votes up vote 4 down vote You can try adding GRANT OPTION at the end: GRANT all privileges on TESTDB.* to 'Max'@'localhost' IDENTIFIED BY 'maxkim' WITH GRANT OPTION; You can also use the below command to find the grants for a user: SHOW GRANTS FOR 'Max'@'localhost'; Also See: MySQL ERROR 1045 (28000): Access denied for user 'bill'@'localhost' (using password: YES) share|improve this answer edited Jul 2 '13 at 12:35 answered Jul 2 '13 at 12:28 Rohit Jain 126k20225331 Thanks, the GRANT OPTION was the key for me –nighthawk454 Jul 18 '14 at 4:12 add a comment| up vote 0 down vote I s
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and
Mysql.connector Python
policies of this site About Us Learn more about Stack Overflow the company mysql error 1045 Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users mysqldb python Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a http://stackoverflow.com/questions/17425523/python-mysql-operationalerror-1045-access-denied-for-user-rootlocalhost minute: Sign up Accessing MySQL from Python 3: Access denied for user up vote 0 down vote favorite I tried to access MySQL from Python 3.3 with the following methods: import mysql.connector config = { 'user': '###', 'password': '******', 'host': '##.##.#.##', 'database': '########', 'port': '####', 'raise_on_warnings': True, } cnx = mysql.connector.connect(**config) cnx.close() but when I ran the above code, I got http://stackoverflow.com/questions/32852163/accessing-mysql-from-python-3-access-denied-for-user this error: mysql.connector.errors.ProgrammingError: 1045 (28000): Access denied for user '###'@'##.##.#.###' (using password: YES); Why am I getting this error, and how can I fix it? python mysql share|improve this question edited Sep 29 '15 at 20:06 ASCIIThenANSI 637321 asked Sep 29 '15 at 19:21 Leo Sun 12 add a comment| 3 Answers 3 active oldest votes up vote 1 down vote This means MySQL has denied the connection for one of these reasons: The username is wrong. The password is wrong. The IP address/hostname you're connecting from is not one that MySQL has been configured to allow for that user. The user does not have access to the specified database. MySQL's users are actually a combination of a user and a pattern for where you can connect from. e.g. 'user'@'10.0.23.99' or 'test'@'%' or 'fred'@'196.168.123.%' or 'mary'@'%.example.com' From a MySQL client check the "user" table in the "mysql" database to see what users MySQL knows about and what hosts the can connect from. Check the MySQL documentation for how to add users. See also how to GRANT access to different tables etc. http://dev.mysql.com/doc/refman/5.5/en/adding-users.html http://dev
1045 25 Jun. 2012 I was working on an OpenStack Essex installation on 2 desktops. Shortly after Ifinished setting up the controller in an all-in-one configuration, and while http://www.tikalk.com/devops/solution-mysql-error-1045-access-denied-userlocalhost-breaks-openstack/ working on the nova-compute node, openstack crashed. The first thing i noticed was an AppArmor popup informing glance-registry has crashed unexpectedly. Further inspection revealed that the 'glance-registry' daemon is starting and https://www.pythonanywhere.com/forums/topic/246/ crashing in an andless loop. All other OpenStack services were inoperational and the nova log files in /var/log/upstart/nova-* were huge. Greping /var/log/glance/registry.logfor 'error' i found this (on the controller): error 1045 2012-06-16 12:57:42 1356 ERROR [glance.registry.db.api] Error configuring registry database with supplied sql_connection 'mysql://glance:openstack@10.0.0.40/glance'. Got error: (OperationalError) (1045, "Access denied for user 'glance'@'ostk-controller1' (using password: YES)") None None This suggested something is wrong with mysql. Testing access from the commandline produced the same error: $ mysql -uglance -popenstack ERROR 1045 (28000): Access denied for user 'glance'@'localhost' (using password: YES) Wondering what change access denied for prvoked this ERROR 1045, i spent hours googling around. There're plenty of ERROR 1045 descriptions, but none of them explained the problem or helped me resolve it - which is the reason for this post. The Problem The logfile of mysqld,/var/log/upstart/mysql.log, reported yet another error: 120618 14:07:31 [Note] /usr/sbin/mysqld: ready for connections. Version: '5.5.24-0ubuntu0.12.04.1' socket: '/var/run/mysqld/mysqld.sock' port: 3306 (Ubuntu) mysqld is alive Checking for tables which need an upgrade, are corrupt or were not closed cleanly. 120618 14:07:36 [ERROR] Cannot find or open table nova/projects from the internal data dictionary of InnoDB though the .frm file for the table exists.Maybe you have deleted and recreated InnoDB data This looked like a DB corruption. Assuming healing it will solve the problem I wasted a few hours on that, in vain. Finally it turned this is a harmless alert that has nothing to do with the Access Denied issue (but is probably a nova bug). Some posts on the subject suggested that the socket permissions prevented local access. In my installation: # ll /var/run/mysqld/mysqld.sock srwxrwxrwx 1 mysql mysql 0 Jun 18 17:34 /var/run/mysqld/my
the python manage.py syncdb, but when i browse it say's Access denied for user. Any thoughts what I having the problem? cmora | 7 posts | Sept. 7, 2012, 8:13 a.m. | permalink Is it MySql? As for me, mySql connection works; There should be right parameters: DB&user name, host (mysql.server), et c kerniexvid | 62 posts | Sept. 7, 2012, 8:56 a.m. | permalink Hi cmora -- what tool are you using to browse the database? giles | 3552 posts | PythonAnywhere staff| | Sept. 7, 2012, 12:14 p.m. | permalink @giles im just using the console to browse the database. If my user parameters is wrong it shouldn't have successfully run the python manage.py syncdb. When i run the syncdb it did create the all my tables. That's why I'm confuse, the syncdb is also using the settings.py so how come it is not working when browse the url. cmora | 7 posts | Sept. 7, 2012, 3:13 p.m. | permalink Ok i try this on my console. python manage.py shell then i import my models and query no error i got. sample: from mysite.models import Table1 Table1.objects.all() [] only means that user account is ok. but when i browse mysite i got this error OperationalError: (1045, "Access denied for user 'cmora'@'ip-10-90-207-138.ec2.internal' (using password: YES)") my settings.py is DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'. 'NAME': 'cmora$default', 'USER': 'cmora', 'PASSWORD': 'notmyrealpassword', 'HOST': 'mysql.server', 'PORT': '3306', } } and my wsgi is activate_this = '/home/cmora/Envs/django/bin/activate_this.py' execfile(activate_this, dict(file=activate_this)) import os import sys path = '/home/cmora/mysite' if path not in sys.path: sys.path.append(path) os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings' import django.core.handlers.wsgi application = django.core.handlers.wsgi.WSGIHandler() Am i doing something wrong in the wsgi? Thanks i