Keep connection

Hi!

I recently created a metabase and succefully connected it to my MySQL database and its working fine, running locally. ( Windows)

But everytime I have to turn off my computer, I have to add again the database to metabase and lose all the work done. When I reconnect, the database is there but I can’t see any data. Just keeps" Loading" and gives an error message in summary graphs. I have to delete, relaunch the java app and add the database again in order to work.

I believe that maybe I skipped some steps? Can you help?

Thank you !

Hi @ritasc
Please post “Diagnostic Info” from Admin > Troubleshooting.
And you should consider setting up a service instead: Run Metabase as a windows service!

Here it is :

{
“browser-info”: {
“language”: “pt-BR”,
“platform”: “Win32”,
“userAgent”: “Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.135 Safari/537.36”,
“vendor”: “Google Inc.”
},
“system-info”: {
“file.encoding”: “Cp1252”,
“java.runtime.name”: “Java™ SE Runtime Environment”,
“java.runtime.version”: “1.8.0_151-b12”,
“java.vendor”: “Oracle Corporation”,
“java.vendor.url”: “http://java.oracle.com/”,
“java.version”: “1.8.0_151”,
“java.vm.name”: “Java HotSpot™ 64-Bit Server VM”,
“java.vm.version”: “25.151-b12”,
“os.name”: “Windows 10”,
“os.version”: “10.0”,
“user.language”: “pt”,
“user.timezone”: “Europe/London”
},
“metabase-info”: {
“databases”: [
“mysql”
],
“hosting-env”: “unknown”,
“application-database”: “h2”,
“application-database-details”: {
“database”: {
“name”: “H2”,
“version”: “1.4.197 (2018-03-18)”
},
“jdbc-driver”: {
“name”: “H2 JDBC Driver”,
“version”: “1.4.197 (2018-03-18)”
}
},
“run-mode”: “prod”,
“version”: {
“tag”: “v0.37.2”,
“date”: “2020-11-16”,
“branch”: “release-x.37.x”,
“hash”: “25e5f70”
},
“settings”: {
“report-timezone”: null
}
}
}

thank you!

@ritasc Migrate away from H2 if you’re using Metabase in production:
https://www.metabase.com/docs/latest/operations-guide/migrating-from-h2.html

Sorry, I’m not very proficient in MYSQL and connections. I could figure it out where to run the fisrt part of the script " export MB_DB_TYPE=mysql
export MB_DB_DBNAME=metabase
export MB_DB_PORT=3306
export MB_DB_USER=
export MB_DB_PASS=
export MB_DB_HOST=localhost".

Can you help me please?

thank you

@ritasc On Windows, you use other ways to set variables. See the top examples here:
https://github.com/metabase/metabase/blob/master/docs/operations-guide/environment-variables.md

I would probably recommend that you either find someone who knows how to setup services on Windows or use the Metabase Cloud, so hosting is done for you: https://www.metabase.com/start/hosted/

Thank you so much!

I tried with ‘set’ and I think it worked .

{
“browser-info”: {
“language”: “pt-BR”,
“platform”: “Win32”,
“userAgent”: “Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.135 Safari/537.36”,
“vendor”: “Google Inc.”
},
“system-info”: {
“file.encoding”: “Cp1252”,
“java.runtime.name”: “Java™ SE Runtime Environment”,
“java.runtime.version”: “1.8.0_151-b12”,
“java.vendor”: “Oracle Corporation”,
“java.vendor.url”: “http://java.oracle.com/”,
“java.version”: “1.8.0_151”,
“java.vm.name”: “Java HotSpot™ 64-Bit Server VM”,
“java.vm.version”: “25.151-b12”,
“os.name”: “Windows 10”,
“os.version”: “10.0”,
“user.language”: “pt”,
“user.timezone”: “Europe/London”
},
“metabase-info”: {
“databases”: [
“h2”,
“mysql”
],
“hosting-env”: “unknown”,
“application-database”: “mysql”,
“application-database-details”: {
“database”: {
“name”: “MySQL”,
“version”: “8.0.20”
},
“jdbc-driver”: {
“name”: “MariaDB Connector/J”,
“version”: “2.6.2”
}
},
“run-mode”: “prod”,
“version”: {
“tag”: “v0.37.2”,
“date”: “2020-11-16”,
“branch”: “release-x.37.x”,
“hash”: “25e5f70”
},
“settings”: {
“report-timezone”: null
}
}
}

thank you!

@ritasc Now, remove the metabase.db.* files (move them somewhere else, trash) and then restart your computer, so you’re sure that all your data is stored in MySQL and you still see "application-database": "mysql" when you look in Diagnostic Info.

I think I’m might be doing something wrong.
I did the above and it worked. And deleted the metabase.db files. But everytime I restart my computer, it restarts the metabase and re-adds the metabase.db.* files .

@ritasc That’s because you are not setting the environment variables before starting Metabase.
https://www.metabase.com/docs/latest/operations-guide/configuring-application-database.html#mysql-or-mariadb

I’m sorry but I think the instructions are a bit confusing.

I did this "

set MB_DB_TYPE=mysql
set MB_DB_DBNAME=mydatabase
set MB_DB_PORT=3306
set MB_DB_USER=
set MB_DB_PASS=
set MB_DB_HOST=localhost
java -jar metabase.jar "

Did I do something wrong? Do I need to do the this step?
« set MB_DB_CONNECTION_URI=“mysql://localhost:3306/metabase?user=&password=”»

I got a bit confuse as you initiate the metabase right after the steps I did.

@ritasc
I would really recommend that you find someone who can run Metabase for you, so you don’t lose your data.

When you start Metabase (java -jar metabase.jar), then it has access to the environment variables set in that session.

I don’t know how you’re starting Metabase, but if you’re using the examples you have provided, then it will use the environment variables to know that should be using MySQL as the application database, and it should not generate the H2 files, when you start Metabase.

I manage to do it, thanks for the help :slight_smile:

for some reason the environment variables were not being saved permantely.