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

Learn how to create a trigger in the H2 database in three easy steps.

Prerequisites

For this tutorial, we’ll need the following in order to open an h2.mv.db file:

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/
				
			
The following image demonstrates what this command should produce when executes successfully:
  • -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.
Terminal output showing the H2 Database server started with several command-line flags; the h2 db web console is available on http://localhost:8082.
Run the h2 database and set the base directory (baseDir) to ~/h2-database/.

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
				
			
The h2 database login page with the JDBC URL set to jdbc:h2:~/h2-database/h2-person.
The h2-person mv.db file will be read from the ~/h2-database/ directory.

Open Your H2 Database in a Browser, Fast!

Learn exactly how to access the h2 db console step-by-step. No guesswork, just a clean walkthrough that works.

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.

H2 web console displaying results from a SQL SELECT query on the PERSON table.
The h2 console including the contents of the PERSON table.

CTO Advisory Services

Collaborate with an experienced technology professional to receive tailored CTO strategy consulting that aligns your technology roadmap with business goals and long-term growth.

That’s it for this section — the conclusion follows.

Step-by-Step: Spring Boot with the H2 Database

This hands-on guide shows how to use Spring Boot with the H2 Database in a single Groovy script -- perfect for fast prototyping and learning.

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.

author avatar
ThosPFuller
I am a software engineer based in Northern Virginia (USA) and this website focuses on content engineering, web development, Technical SEO, Search Engine Optimization (SEO).

Leave a Reply