How to see the specific data in H2 database

Users registering for Metabase are all stored in a file named “metabase. db. mv. db”. How can I view the specific data in the file?

I tried using the command java-cp metabase.jar org.h2.tools.Server-web


But what are the usernames and password?

@zsk
There isn’t any username or password for that database by default.
It is not recommended to use H2 in production, you should migrate to another database:
https://www.metabase.com/docs/latest/operations-guide/start.html#migrating-from-using-the-h2-database-to-mysql-or-postgres

Okay, I’d like to try to replace the H2 database with Mysql in the production process.

If the Mysql database is replaced, is there any requirement for the encoding of the database? If so, what should the character set and sorting rules be?

@zsk
If you choose MySQL (I would recommend MariaDB), then you should use charset utf8mb4_unicode_ci.

If you use MySQL 8, then you need to use mysql_native_password instead of caching_sha2_password for user credentials (otherwise you’ll see an error)

Not sure what you mean by “encoding of the database” ?

The character set I am using at present is UTF-8, and the sorting rule is utf8_unicode_ci.


But it’s scrambled.

@zsk
What do you normally use for charset/collation? Then use that.
You should not be using utf8 - you should use utf8mb4.

Hello, the character encoding of the database is as follows when doing data migration.
image
But there is still a scrambling problem.

@zsk
It looks like you’re showing column query.query_hash, which should be a binary(32) type, so it shouldn’t be affected by any encoding.

You’re right. He’s really a binary (32) type, but in my opinion my data is more like garbage. What do you think?

@zsk It’s not supposed to be viewed by humans - it’s for computer eyes only :robot:

Thank you very much for your answer? So how do I test that the stored values are correct? (What functions or buttons should I manipulate to invoke the data in this table)

@zsk
I don’t understand your question. The data is correct - it’s binary, so encoding should not have any impact on that column.
The data inside query.query_hash is a sha256 hash (if I remember correctly). It is used as an identifier to other tables such as query_cache and query_execution - and as a check if data has changed (cache).

As you said, I tried without any mistakes. I think it is possible. Thank you very much.

By the way, if I use Nginx to load balance multiple instances of Metabase and use the default polling strategy, will it cause the problem that sessions cannot be shared?

@zsk I don’t know what “default polling strategy” means. You should use sticky connections, so each session stays with the same instance.

I’m sorry I didn’t reply to you in time. But if all the users are in the LAN, then my nginx doesn’t work. Because the users in the LAN are treated as the same’IP’address by nginx