SA-MP Forums Archive
Linking LocalHost(Server) to Dedicated Server MySQL Database - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Linking LocalHost(Server) to Dedicated Server MySQL Database (/showthread.php?tid=623839)



Linking LocalHost(Server) to Dedicated Server MySQL Database - Tass007 - 06.12.2016

Hey guys. I want to do some testing on my local server so I don't have to keep uploading to the Dedicated server all the time however I keep getting errors (From my local server).

Basically long story short: I have a dedicated server that has a MySQL database linked to it. For the MySQL database information in the script is.

Код:
#define 	MYSQL_HOST			"127.0.0.1"
If I upload to the dedicated server and do anything with the database it works completely fine.

Then on my dedicated server I created a RemoteMySQL thing whatever it is. (I talked to the company and they said that's how you did it.) So I set the RemoteMySQL up setting it to my IP address. Then in the script I set the MYSQL_HOST to the dedicated server's IP address (no ports) and then when I tried to start up my server the connection failed and I got this error message.

Код:
(error #1042) Can't get hostname for your address
I'm not sure if the fact that my local host is Windows and the dedicated server is Linux that's breaking it. Or just that I've set something up wrong. But here is my MySQL connection info in the script.

PHP код:
    mysql_log(LOG_ALLLOG_TYPE_HTML);
    
ServerMySQL mysql_connect(MYSQL_HOSTMYSQL_USERMYSQL_DBMYSQL_PASS);
    if(
mysql_errno() != 0
    { 
        
printf("[MySQL] The connection has failed."); 
    } 
    else 
    { 
        
printf("[MySQL] The connection was successful."); 
    } 
If you have any ideas please let me know.

Thanks for your time


Re: Linking LocalHost(Server) to Dedicated Server MySQL Database - iLearner - 06.12.2016

127.... Host is localhost, I am pretty sure you don't have mysql on your pc


Re: Linking LocalHost(Server) to Dedicated Server MySQL Database - Tass007 - 06.12.2016

Yes I know like I said above. When trying to start my local host server I set the MYSQL_HOST to the dedicated server's IP address with no ports. But it doesn't work. If I am to set it to 127.0.0.1

Код:
(error #2005) Unknown MySQL server host '127.0.01' (0)
Quote:
Originally Posted by Tass007
Посмотреть сообщение
Then in the script I set the MYSQL_HOST to the dedicated server's IP address (no ports) and then when I tried to start up my server the connection failed and I got this error message.



Re: Linking LocalHost(Server) to Dedicated Server MySQL Database - Tass007 - 07.12.2016

Bump


Re: Linking LocalHost(Server) to Dedicated Server MySQL Database - Dayrion - 07.12.2016

You must have MySQL (use xampp for example) on your PC and this
PHP код:
#define    MYSQL_HOST        "localhost" 
#define    MYSQL_USER        "root" 
#define    MYSQL_DATABASE    "myserver" // change this 
#define    MYSQL_PASSWORD    "" 



Re: Linking LocalHost(Server) to Dedicated Server MySQL Database - Tass007 - 07.12.2016

This is the whole thing. I want to connect to the Mysql database that is connected to my dedicated server so thst I can test things through my local host and be able to have the same database as my dedicated server. Im pretty sure that this is possible I just need to know how to fix this error


Re: Linking LocalHost(Server) to Dedicated Server MySQL Database - Dignity - 07.12.2016

Quote:
Originally Posted by Tass007
Посмотреть сообщение
This is the whole thing. I want to connect to the Mysql database that is connected to my dedicated server so thst I can test things through my local host and be able to have the same database as my dedicated server. Im pretty sure that this is possible I just need to know how to fix this error
127.0.0.1 / localhost uses MySQL on the machine it's called on. If you use 'localhost' locally, it will try to load the MySQL server on your local machine. If you want to use the database linked to your dedicated server, you have to use the IP of the service that hosts the MySQL server, usually your dedicated machine.

You can still use localhost when you are calling it from your dedicated because then it will load the MySQL server through your dedicated server.


Re: Linking LocalHost(Server) to Dedicated Server MySQL Database - Tass007 - 07.12.2016

Quote:
Originally Posted by Dignity
Посмотреть сообщение
127.0.0.1 / localhost uses MySQL on the machine it's called on. If you use 'localhost' locally, it will try to load the MySQL server on your local machine. If you want to use the database linked to your dedicated server, you have to use the IP of the service that hosts the MySQL server, usually your dedicated machine.

You can still use localhost when you are calling it from your dedicated because then it will load the MySQL server through your dedicated server.
That's what I'm trying to do. When I define the mysql host I'm putting the ip address of the dedicated server however I'm getting the error. Do I need to change other things? Also I want to use the database linked to the dedicated server and not one off my local host because I don't want to have to worry about chopping and changing things especially because I work with a scripting team.


Re: Linking LocalHost(Server) to Dedicated Server MySQL Database - Dignity - 07.12.2016

Quote:
Originally Posted by Tass007
Посмотреть сообщение
That's what I'm trying to do. When I define the mysql host I'm putting the ip address of the dedicated server however I'm getting the error. Do I need to change other things? Also I want to use the database linked to the dedicated server and not one off my local host because I don't want to have to worry about chopping and changing things especially because I work with a scripting team.
Are you sure the ip is correct and allows connections from a different source?