So I’m learning Django (1, 3, 1, ‘final’, 0) through this resource: http://www.djangobook.com/en/2.0/chapter05/
I installed ‘mysql-server’ and ‘python-mysqldb’ via Synaptic. I changed the relevant setting in settings.py.
The book mentioned above tells us to run from the manage.py shell:
>>> from django.db import connection
>>> cursor = connection.cursor()
I get this error after running these commands:
OperationalError: (1044, "Access denied for user ''@'localhost' to database 'mydb'")
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/usr/lib/python2.7/dist-packages/django/db/backends/__init__.py", line 250, in cursor
cursor = self.make_debug_cursor(self._cursor())
File "/usr/lib/python2.7/dist-packages/django/db/backends/mysql/base.py", line 322, in _cursor
self.connection = Database.connect(**kwargs)
File "/usr/lib/python2.7/dist-packages/MySQLdb/__init__.py", line 81, in Connect
return Connection(*args, **kwargs)
File "/usr/lib/python2.7/dist-packages/MySQLdb/connections.py", line 187, in __init__
super(Connection, self).__init__(*args, **kwargs2)
OperationalError: (1044, "Access denied for user ''@'localhost' to database 'mydb'")
MySQL did ask me to set a root password when I installed it the first time, would that be utilized here? or is it something else?
Your user does not have an access to database. Use the commands below to set up your database.
Also, you need to have enough privileges to run it. Save it as script.sql then,
Than on to settings.py where you need to make sure your db settings are set up properly
and
and you’re done.