0

So I have a MySQL database for my Django project which I think is located in the default directly (wherever that should be). When I want to move my Django project to digital ocean, how do I move that database? The my.cnf file is located inside the same directory as the settings.py file for the Django project. I am using macOS.

In short: How do I copy my database file to my Django project directory and reconfigure its path to that?

3
  • You should dump and reimport the data. Commented May 13, 2020 at 3:58
  • @KlausD. How do I do that? Could you maybe provide some link? Commented May 13, 2020 at 4:14
  • This is actually a system administration and not a programming task. It is off-topic for Stack Overflow. But any search engine is able to find leads on how to dump a database. Commented May 13, 2020 at 4:20

2 Answers 2

0

Compare the MySQL versions of both servers. Ensure the new version isn't less than the current version. Also check its not two major versions ahead of the current one.

Ensure MySQL is stopped.

Copy/move the entire datadir to the new location. There should be no files in this new location that weren't in the original.

In the my.cnf file set datadir to the new location.

Copy the my.cnf file to the location where mysql is expecting to read this on the new server. Look at top of mysqld --help --verbose if you have doubts where this is.

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

Comments

0

There are many things to consider here,

  • In Digital Ocean you would have MySQL server running on same machine as the Django server i.e just like your local machine?
  • If yes then you might not have to change anything on django settings (if you keep user and password same as local).
  • If No, you might need to change host in django to IP of that server(there are many things involved here...)
  • Regarding the data transfer, it is always the best practice to dump MySQL and Import it in new DB. There are many guides available on web. Here is one from Digital ocean.

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.