How to migrate SQLite Database to MYSQL in Django
Posted: 20 Oct 2019
I am struggling in migrating SQLite to MYSQL in django and searching for best way to do so. If anyone knows then please guide the way to do so.
Discussion Zone for AI Aspirants
https://aisangam.com/fixerrors/
If not, then the answer is through drivers. Let me write down belowDo you know how python programs are interfacing with the databases.
Code: Select all
pip install mysqlclient
Code: Select all
mysql -u root -p
Code: Select all
CREATE DATABASE **your_project_name** CHARACTER SET UTF8;
Code: Select all
GRANT ALL PRIVILEGES ON your_project_name.* TO your_username@localhost;
Code: Select all
FLUSH PRIVILEGES;
Code: Select all
QUIT
Code: Select all
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
Code: Select all
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': '', # Name of database
'USER': '', # user may be root or anything else
'PASSWORD': '', password you login for mysql
'HOST': 'localhost',
'PORT': '',
}
}