Learn how to open an mv db file for the h2 database in three easy steps!
This DB dev guide provides software engineers with a step-by-step walkthrough regarding how to open a .mv.db file in the H2 Database (h2).
H2 is heavily used in software projects and testing efforts due to its lightweight and in-memory capabilities as well as seamless integration with Java-based applications.
An mv.db file is the main data storage file used by h2 when operating with the MVStore engine and contains tables, indexes, and transaction data, and is automatically created when h2 is initialized.
This article was updated on June 04, 2025.
Set Up Your H2 Database Trigger in Minutes
Prerequisites
For this tutorial, we’ll need the following in order to open an h2.mv.db file:
- Java version 22.0.1 (required) — see OpenJDK on java.net and Oracle Java SE Development Kit 22.0.1 (JDK 22.0.1)
- The H2 Database Engine dependency.
- An example database to work with (or we can create one ourselves).
SQL script for an example h2 database
We provide an example script as a gist on GitHub in the event that you need to create your own database.
Step One: Start the h2 database from the command line.
The first step in this exercise is to run the h2 database — we do so via the command line, which can be seen here:
java -cp ~/.groovy/grapes/com.h2database/h2/jars/h2-2.3.232.jar org.h2.tools.Server -ifNotExists -web -browser -baseDir ~/h2-database/
- -ifNotExists: Creates the database only if it doesn’t already exist.
- -web: Starts the h2 db web server, which provides access to the browser-based console.
- -browser: Automatically opens the h2 db web console in the default browser.
- -baseDir ~/h2-database/: Sets the base directory for database files to the ~/h2-database/ directory.
One the h2 database has started successfully we should see a message in the console output that reads:
Web Console server running at http://localhost:8082 (others can connect)
Step Two: Login to the h2-person database.
Once step one is completed and the h2 database web console login page is opened, we can chance the JDBC URL to point to the h2-person .mv.db file using the following URL.
jdbc:h2:~/h2-database/h2-person
Open Your H2 Database in a Browser, Fast!
Warning: We do not include the full filename in the JDBC URL — if we were to use h2-person.mv.db then a new and empty database will be created called h2-person.mv.db.mv.db and this is not what we want.
Step Three (OPTIONAL): Review the PERSON table.
We can review the PERSON table in the H2 Console Application by executing a select operation such as:
SELECT * FROM PERSON;
The lower right side of the image below includes the expected output once the data is returned.
CTO Advisory Services
That’s it for this section — the conclusion follows.
Step-by-Step: Spring Boot with the H2 Database
Article Conclusion
As mentioned earlier in this article, the .mv.db file is central to H2’s storage mechanism and encapsulates all persistent data.
By leveraging tools like the H2 web console as well as being aware of best practices, you can ensure efficient and reliable interactions with your H2 database instances.
Questions and comments are welcome.











