Genie.jl icon indicating copy to clipboard operation
Genie.jl copied to clipboard

SO: Error connecting a MySQL database in Genie.jl

Open essenciary opened this issue 4 years ago • 7 comments

Per: https://stackoverflow.com/questions/70927061/error-connecting-a-mysql-database-in-genie-jl

essenciary avatar Jan 31 '22 17:01 essenciary

@logankilpatrick Let's follow up here regarding the SO issue. I mentioned there that your MySQL config is not correct - you need to pass host, username, and password and the valid name of an existing database on that server. In addition, I need info on how you're loading the app (what steps did you take to get that error).

essenciary avatar Jan 31 '22 17:01 essenciary

Ah got it, so the command does not create a new database for me? I have to manually go and create one?

logankilpatrick avatar Jan 31 '22 21:01 logankilpatrick

I am currently just following this tutorial: https://genieframework.com/docs/tutorials/Developing-MVC-Web-Apps.html#connectingtothedatabase line by line

logankilpatrick avatar Jan 31 '22 21:01 logankilpatrick

If genie does not create the database automatically, what are the steps I need to take to do so? Can you link me to an article? I am coming from Django where the DB is created and wired up automatically. I would also propose adding a note on this in the docs so folks know what the expectation is

logankilpatrick avatar Feb 01 '22 03:02 logankilpatrick

The MySQL database is created automatically?

  • in order to connect to the MySQL server you definitely need to provide host, username and password
  • once connected, your web app user (the one used for connecting) must have database creation privileges - which is usually not the case and is a bad idea (the web user is more restricted in order to avoid privilege escalation issues through vulnerabilities in the web app)

essenciary avatar Feb 01 '22 08:02 essenciary

Ex: https://medium.com/@omaraamir19966/connect-django-with-mysql-database-f946d0f6f9e3 Db and user have to be created by hand then used in the Django app.

SQLite is a different thing, maybe that's what you have in mind. SQLite is a file based DB - and yes, that is created automatically, you just need to provide the path where you want it to be created/stored.

essenciary avatar Feb 01 '22 08:02 essenciary

If genie does not create the database automatically, what are the steps I need to take to do so? Can you link me to an article? I am coming from Django where the DB is created and wired up automatically. I would also propose adding a note on this in the docs so folks know what the expectation is

If you are free choosing your tools for your own the easiest way is to use MySQLWorkbench. There you will find the way to create a schema aka database intuitively. Maybe Adrian could think about to create a database only in dev mode. In production mode it is very dangerous as Adrain stated.

FrankUrbach avatar Feb 02 '22 19:02 FrankUrbach