I seem to recall that some time ago, LP did not allow scripts (e.g., PHP) to create databases. Nevertheless, there must be some way for Softaculous and other installers to perform this task. I presume there is some sort of programmatic interface to allow such tasks -- have you looked at your "one-button" installer used on your account control panel to see if you can decipher their installation scripts?
Is this on a cPanel or an LPCP account? I ask because too many people refer generically to an account control panel as "cPanel", when in fact that is a specific brand (used on older LP servers... the newer ones use LPCP). If you intend to make this installable by others, including at non-LP hosts, I would assume that there is some sort of generic DB creation call, if in fact the MySQLi interface is not supported. I assume that you're prereq'ing MySQLi, as not all hosts may have it installed yet.
Note that at LP, cPanel installations used "localhost", while LPCP used a separate, named, DB server (e.g., mysql35.lunariffic.com). I think in both cases, both the user name and the DB name have your account name prepended. Maybe your $dbname is bad? Also, PHP does fine with 644 permissions, although if you want to make this usable across multiple hosts, 755 might be necessary. Just don't use 666 or 777, as many hosts (including LP) will block it as a security hazard. You might want to google for installer formats and maybe ask on a place like StackOverflow what other applications do about building their installers (if you're currently doing it by trial and error).
By the way, it's not a good idea to publicly display your account name. It's a security risk. I will edit your post to remove it.