Forums

django.db.utils.OperationalError: (1227, 'Access denied; you need (at least one of) the SYSTEM_VARIABLES_ADMIN or SESSION_VARIABLES_ADMIN priv

Hi,

I am a newuser on pythoneverywhere.

I am experiencing the following error when I try to create a superuser on bash console python manage.py createsuperuser The Error is as follows django.db.utils.OperationalError: (1227, 'Access denied; you need (at least one of) the SYSTEM_VARIABLES_ADMIN or SESSION_VARIABLES_ADMIN priv

I have tried giving my access through various means as create user command as below but I keep getting the command

ERROR 1227 (42000): Access denied; you need (at least one of) the CREATE USER privilege(s) for this operation

Any help very much appreciated. My user Steps so far

Go to https://www.pythonanywhere.com/user/Bill/databases/ 1. create database mfdw_db 2. set password xxx

I know the database is created and that I have the packages installed as I run the following commands from a bash console Tempwap is my username

mysql -u *Tempwap -h Tempwap.mysql.pythonanywhere-services.com -p 'Tempwap$mfdw_db'*;

output message Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 23475310Server version: 8.0.32 Source distributionCopyright (c) 2000, 2022, Oracle and/or its affiliates.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

Its then when I try the following to give myself access I get repeated errors create user 'Tempwap'@Tempwap.mysql.pythonanywhere-services.com' IDENTIFIED BY 'xxx';

ERROR 1227 (42000): Access denied; you need (at least one of) the CREATE USER privilege(s) for this operation

How should I go about resolving the errors - any help much appreciated ?

When you set up the MySQL database on the "Databases" page, your user with username Tempwap is already created with the appropriate permissions; you don't need to use create user to create it again.

Hi Thank you that's good to know, it rules out those options of changing priviliges.

However I still have problem when I run the following command ?

python manage.py createsuperuser

django.db.utils.OperationalError: (1227, 'Access denied; you need (at least one of) the SYSTEM_VARIABLES_ADMIN or SESSION_VARIABLES_ADMIN priviliges

I thought that by changing priviliges I could get round this error but from what you have said earlier post this is not the way to do it, Question: is there another way to get round this error or why is it throwing this error ?

Much appreciate all your advice and help to date thank you

how does your DATABASES config look like?

Hi, Apologies for the delay and thank you for the device.

Can I ask where is my databases config file is and what should it be set too ?

My settings files is as follows - this is the only file I thought that could cause the problem

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'Tempwap$mfdw_db',
        'USER': 'Tempwap',
        'PASSWORD': 'xxx',
 #       'TEST': {'NAME': 'Tempwap$mfdw_db'},
        'HOST': 'Tempwap.mysql.pythonanywhere-services.com',
      'OPTIONS': {
            'init_command': "SET sql_mode='STRICT_TRANS_TABLES', innodb_strict_mode=1",
            'charset': 'utf8mb4',
            "autocommit": True,
        }
    }
}

Looks like 'init_command': "SET sql_mode='STRICT_TRANS_TABLES', innodb_strict_mode=1", in the OPTIONS dict is the culprit here -- I tried to create a superuser with those and got the same error.

EDIT: looks like innodb_strict_mode=1 is the actual cause here.

Hi, Thank you to all for your help

I was not getting anywhere so I moved on to another application.

Thanks to all

Fair enough. Thanks for letting us know.