Forums

MySQL Database name change

Dear all I am not really good at Python language, Can any one help me to kno how I can Change the database name, Now My system goes down and I received notification from pythonanywhere saying that is because of a database name change that they disabled the mysql.server hostname for MySQL databases. Please help me to bring back the system online.

Dear rba,

I think people will need a bit more detail to answer you - are you using a 'web app', Django, Flask, Python code running in a bash shell or scheduled task, SqlAlchemy or ...?

HTH

Jim

I am Using Web App

Somewhere it must include the string 'mysql.server'? You'll need to change it to the new address as described by PA.

Hi rba -- we'll respond via email as well, but here are some instructions. I do recommend that you get a Python developer on retainer, though, to handle things like this in the future. From time to time we have to update PythonAnywhere for maintenance or security changes, so this won't be the last time you'll have to do something programming-related.

I think you're using a web2py app. You need to:

  • Log in to the admin interface
  • Click on the "Manage" dropdown for the application that hosts your site. (It should have a reasonably recognisable name -- the programmer who developed your site will have named it.)
  • In the dropdown, you'll see an "Edit" option. Click that.
  • On the page that appears, there will be a magnifying glass "Search" field at the top. Type DAL into there and hit return; this will search through the code for all files that include the string "DAL", which is how the database connection is specified in web2py.
  • You will see a list of files, in a number of sections. Hopefully there will be one called something like db.py. Click the "Edit" button next to it.
  • Inside that file, you'll see a line that says something like this:

db = DAL('mysql://rba:something@mysql.server:3306/rba$something',pool_size=1)

  • You need to replace the mysql.server with rba.mysql.pythonanywhere-services.com, and add , fake_migrate_all=True before the closing bracket.
  • Once you've done that, click the "Save" button.
  • Visit your site.
  • Go back to the page where you were editing the code, and remove the , fake_migrate_all=True but leave the change from mysql.server with rba.mysql.pythonanywhere-services.com there.
  • Save again.

Once you've done that, it should work fine.

Thank you for your help. It worked!!

Great! Glad I could help :-)