How to Migrate MySQL from DBngin to Laravel Herd

Ever since Laravel Herd Pro was launched with the ability to manage database and cache services like MySQL, Postgres, and Redis, I've been wanting to switch from DBngin to Herd's MySQL and Redis.

Recently, with a little help from Marcel Pociot, I was able to figure out an easy way to move all my local databases over to Herd's MySQL service without losing any data.

Warning before getting started, if you have any databases that are really important and you can't risk losing them, make a backup before following any of these instructions. I'm not responsible if something goes wrong and you lose some important data.

Note: this method will only work if your MySQL services are on the same minor release version. For example: v8.0.33 to v8.0.36 will work. v8.0 to v8.2 will not work.

1. Stop DBngin's MySQL service.

To stop DBngin's MySQL service, open the DBngin app and click stop beside the MySQL service.

2. Create the MySQL service in Herd

Open Laravel Herd, and go to the "Services" tab. Click "Add Service" and create the MySQL service. I would suggest stopping the Herd MySQL service after it's added so we can safely move the data without corrupting anything.

3. Copy the data from DBngin to Herd

First, you need to find out where DBngin stores all your database files. I found them the hard way, but Marcel told me an easier way. Open DBngin, right-click on the MySQL service, and click "Show database files". It should open a "mysql" folder that has a single folder inside. Open that folder, and you should see a folder for every database you have, plus some other configuration files and folders.

To find out where Herd plans to store your databases, we can follow a similar path. Open Herd's "Services" tab again, right-click the MySQL service, and click "Open data directory". It should open the exact folder where it stores the files.

Now, copy all the files and folders from the DBngin folder to the Herd folder.

4. Restart the MySQL service in Herd

Once all the files are copied over, open up Herd to the "Services" tab and restart the MySQL service. Open up your database management tool of choice, connect to the MySQL service (probably using the same settings you were using previously), and you should see all your databases listed!

Now, if you want to, and you're not using DBngin for other services (or have migrated them all to Herd), you can uninstall DBngin. One less app/service to maintain on your Mac.

Conclusion

I've really been enjoying the simplicity Herd and Herd Pro bring to the Laravel development experience. It's so simple to set up and includes pretty much everything needed for typical Laravel development these days. I can't wait to see what they add next!

Let me know what your favorite Herd features are on Twitter.


The post How to Migrate MySQL from DBngin to Laravel Herd appeared first on Laravel News.

Join the Laravel Newsletter to get all the latest Laravel articles like this directly in your inbox.