Roundcube with mySQL on Windows

I was doing maintenance on my backend Windows server, and part of this was upgrading Roundcube mail to the latest LTS version (1.5.9). On Windows, like lots of open-source software designed for Linux, it's a manual process. Install and upgrade scripts many times don't work and/or don't exist for Windows.

I noticed Roundcube was running on sqlite rather than the main mySQL 8.0 database. I don't like to have separate SQL database platforms on the same server for things, and I noticed past Tom tried to get mySQL to work but gave up. I went with the easier sqlite when I moved my Roundcube install from Linux to Windows 3 years ago (my guess is the web installer failed to initialize the mySQL database, but I don't remember). Not a big deal, but I decided to fix it while I was upgrading and I wasn't able to find a complete guide how to do it online (so I'm sharing).

On the mySQL side you need to create a Roundcube database and user, and then run the Roundcube SQL script to initialize the database (the SOURCE line below). In the Command Line Client, you need to run something like this (adjust the paths and password accordingly):

SHOW DATABASES;
CREATE DATABASE roundcubemail;
CREATE USER 'roundcube'@'localhost' IDENTIFIED BY 'mypassword';
GRANT ALL PRIVILEGES ON roundcubemail.* TO 'roundcube'@'localhost';
FLUSH PRIVILEGES;
USE roundcubemail;
SOURCE C:/mypath/roundcube/SQL/mysql.initial.sql;
QUIT;

In the Roundcube configuration file ("C:\mypath\roundcube\config\config.inc.php"), modify the database line to this:

$config['db_dsnw'] = 'mysql://roundcube:mypassword@localhost/roundcubemail?verify_server_cert=false';

Then restart services (or reboot) and you are good to go.