Jump to content

Allow my website to connect to my MySQL server

So for the last 2 months i have been working on a multiplayer game and i just got myself a VPS to run my multiplayer handler on.
I use a MySQL database to save all the user information and on the VPS i can connect to my MySQL server without any problems(because the database is hosted on my VPS).

Now i want my website to connect to the database on my MySQL server but i cannot connect to the host...
http://prntscr.com/a5bfd7 (screenshot from websites my error page).

The config is the same as the one i use to make my multiplayer handler connect to the database but instead of using 'localhost' i use the IP-adres of the VPS.

So the problem is, i cant get my website to connect to my MySQL database.
i hope u guys know the answer

Some more information:
OS on my VPS: Windows server 2012 R2
MySQL server version: 5.7

My profile picture says enough

Link to comment
Share on other sites

Link to post
Share on other sites

Which Web Server are you using? (Apache, Nginx)

And what are you trying to use to connect to the DB? (PHP, Ruby, Python)

CPU: I7 4790k | Motherboard: Asus Maximus VII Hero | RAM: Corsair Vengeance 16GB DDR3 1866Mhz | GPU: EVGA GeForce GTX 980 Ti 6GB Superclocked+ ACX 2.0+ | Case: Corsair Carbide 500R | Storage: SSD Samsung EVO 850 250GB, 2 * 1TB 7200rpm HDD | PSU: EVGA 600b 80 plus bronze | Display(s): Asus PB287Q | Cooling: Noctua NH-D14 | Keyboard: Corsair K70 Cherry MX Red | Mouse: Logitech G502 | Operating System: Windows 10 PRO

Link to comment
Share on other sites

Link to post
Share on other sites

1 hour ago, Luraguse said:

Which Web Server are you using? (Apache, Nginx)

And what are you trying to use to connect to the DB? (PHP, Ruby, Python)

Apache and PHP.

My profile picture says enough

Link to comment
Share on other sites

Link to post
Share on other sites

After the mysql_connect(params) try doing an

echo mysql_error();

It should display what the problem is

 

http://php.net/manual/en/function.mysql-error.php

CPU: I7 4790k | Motherboard: Asus Maximus VII Hero | RAM: Corsair Vengeance 16GB DDR3 1866Mhz | GPU: EVGA GeForce GTX 980 Ti 6GB Superclocked+ ACX 2.0+ | Case: Corsair Carbide 500R | Storage: SSD Samsung EVO 850 250GB, 2 * 1TB 7200rpm HDD | PSU: EVGA 600b 80 plus bronze | Display(s): Asus PB287Q | Cooling: Noctua NH-D14 | Keyboard: Corsair K70 Cherry MX Red | Mouse: Logitech G502 | Operating System: Windows 10 PRO

Link to comment
Share on other sites

Link to post
Share on other sites

My first guess would be the firewall on your VPS is configured to not allow external connections to the MySQL server

Link to comment
Share on other sites

Link to post
Share on other sites

Just now, Brenz said:

My first guess would be the firewall on your VPS is configured to not allow external connections to the MySQL server

The firewall is off, i port forwarded my sql port, allowed my webhosting to connect but it still doesn't work ;(

My profile picture says enough

Link to comment
Share on other sites

Link to post
Share on other sites

1 minute ago, UltraCakeBakery said:

The firewall is off, i port forwarded my sql port, allowed my webhosting to connect but it still doesn't work ;(

Well first of all turn the firewall back ON and configure it properly. Never turn the firewall off especially on a server.

 

Try using some software like MySQL Workbench to see if you can access the server from your PC. If not its likely you have something configured wrong in your port forwarding or on the server.

Link to comment
Share on other sites

Link to post
Share on other sites

If you have the IP address (besides the named pipe) for the MySQL server, try MySQL workbench to connect as a root user. If it connects then you probably have something mis-configured and you need to recheck your settings. Also try to contact your server administrator (if you do not administer the server yourself) and ask him to try to connect to the server.

Link to comment
Share on other sites

Link to post
Share on other sites

In the config file for mysql, there should be a bind address that is set to 127.0.0.1, change that to the internal ip address of your server. Then run this query 

GRANT ALL PRIVILEGES ON *.* TO 'username'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;

Reboot the mysql server and it should work.

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×