0

Apologies in advance if this type of question already exists with a solution. I have been trying to get this solved for about 2 weeks now. So I had a Django project, which initially used the default Django database : SQLite3. I was able to access that database using /admin with the localhost, with 'admin' as password and username. I shifted the database to MySQL and everything was transferred properly, but I am not sure how to access the data using the /admin now. What should I enter in the username and password section? I have tried every possible combination with 'admin', database name, username, hostname and password which is provided in the settings.py when you change database.

For reference, this is what the database section of my settings.py looks like

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'project',
        'USER': 'root',
        'PASSWORD': 'mysql-password',
        'HOST': 'localhost',
        'PORT': '3306',
    }
}
1
  • In the /admin section, you should give a Django username and passwords, so something from a table inside the database you are trying to admin. If you migrated your SQLite3 database to MySQL, the user should be the same as before. If not, you can create a new superuser or override the password of an existing superuser from the command line. See docs.djangoproject.com/en/4.2/topics/auth/default/… for more information on creating superusers and/or changing their passwords from the command line. Commented Oct 8, 2023 at 7:06

1 Answer 1

1

Chances are that your admin user got lost along the way with this transition from SQLite to MySQL, no worries, I'll provide some instructions down below to create a new one.

There is one thing I would like to mention in order to give you some more context regarding the database configuration in your settings.py file. The USER and PASSWORD credentials that you set over there, are used for connecting to the database itself. This doesn't have anything to do with the admin section of a Django application.

Now in order to create a new admin user, you can follow the steps in the terminal by entering the following command:

python manage.py createsuperuser

Make sure that you enter this command in the root of your project and with your virtualenvironment activated if you have one.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.