This should work using our Migration plugin. You can install this plugin on your WordPress instance. Afterwards you can for example run the command like this:

php wp-content/plugins/matomo/app/console migration:measurable --source-idsite=1  --target-db-host= --target-db-username=root --target-db-password=secure --target-db-name=matomo2

In most cases the source-idsite should be 1. You can find the correct value in the Matomo for WordPress system report under the « Matomo Blog idSite » setting.

We can also migrate your Matomo for WordPress data to our Matomo Cloud.

Previous FAQ: How do I import data from WP Statistics plugin into Matomo for WordPress?