So I bought a new VPS for first time and tried to connect mysql database to it and whenever I run the server it gives me this error "mysqli_connect(): Access denied for user 'root'@'localhost'" I've been trying all day to get it fixed but can't seem to find a way Here's the code: public function onEnable() { $this->getServer()->getPluginManager()->registerEvents($this, $this); $this->getLogger()->info("BowCommand Enabled"); $dbServerName = "127.0.0.1"; $dbUsername = "root"; $dbPassword = "MyPassword"; $dbName = "minecraft"; $conn = mysqli_connect($dbServerName, $dbUsername, $dbPassword, $dbName); echo "worked"; }
I think is work PHP: $mysql = new \mysqli($dbServerName, $dbUsername, $dbPassword, $dbName);if($mysql->connect()){$this->getLogger()->info("Mysql Can connect");}else{$this->getLogger()->info("Mysql Can't connect");}
Apparently there is something wrong with your setup. Can you connect to your localhost using same credentials from elsewhere? This question is already answered, many times and has nothing to do with the pocketmine nor with php itself. https://stackoverflow.com/questions...y000-1045-access-denied-for-user-usernameloca
Yeah. I’ve tried to login from the terminal multiple times and it works but when I try using it with php it just doesn’t work
Also, I’m not sure if I should put my VPS ip instead of local host but when I do it says “Connection refused”
Localhost refers to the local network on which the software is running. From what I understand is that your mysql server is on the VPS. So if you'd like to connect to it, while referring to localhost, then the plugin must be running on the VPS. And if you're trying to connect to it while outside of it, i.e. your computer (by definition its remote connection), then the port must be open and mysql server configured to accept/authorize/handle such connections. Read this article if that is the case: https://phoenixnap.com/kb/mysql-remote-connection