MySQL : How to fix Can't connect to MySQL server on localhost 10061 error

When I installed MySQL server a few months ago on my Windows 10 machine, I chose to have the database files on my main SSD drive. As it was slowly filling up, I decided to migrate the MySQL database files to another drive. I assumed all I needed to do is to update a path for datadir option in my.ini
configuration file, but that didn't work. After the database location move, starting the MySQL server gave me 10061 error "Can't connect to MySQL server" error. Luckily, the fix was quite simple.