I'll deal with your problems in reverse order, firstly, is your SSL certificate self-signed? i.e. not issued from a proper authority? if it is (which I suspect) then you WILL get the message that you are seeing. Until you buy a authoratitive cert from a registered provider you'll continue seeing the message.
On the side about the database, i'm assuming that the database has been set up in Plesk using the plesk database tool for it. "Create a database", and "Add User", and i'm also assuming that you have this script on the same server (hence the connecting to localhost).
Now, I realise you're working with a virtual server, so is it the case that you set up the virtual server on the machine, or your hoster set it up for you? The error 10061 is usually indicative that you have not started the MySQL daemon, or it is failing to start. Do you have root access in your virtual server? If so you can do
/sbin/service mysqld status
It might show a "locked" message, in which case you need to stop/start it again. And check your logs (/var/log/mysqld/...)