mysql on different server
-
I am adding a wordpress blog to a site, but i want to keep all my existing server. The site i am adding wordpress to is on a diffrent server than the database so “localhost” will not work when i define the database in the config file.
Can someone push me in the right direction.
-
I don’t know of a host that will let a database be accessed from outside their own system. You need to talk to them first.
my host just told me that they would open the port….
However, Is this going to make my – sql server vanerable?
I asked my host this question and they told me they have done this for other clients and have not had any problems.
what i need to be able to do is specify the port to connect to the database in the config file. I know the port, but i don’t know exactly how i would do this.
If someone has done this or knows how i would do this, please help…Thanks
Probably something like serveraddress:XXXX – where XXX is the port.
No guarantee! it’s just an idea…thanks…i tried that a few different ways, i also tried PORT and still can not get it to work.
// ** MySQL settings ** //
define(‘DB_NAME’, ‘*****’); // The name of the database
define(‘DB_USER’, ‘******’); // Your MySQL username
define(‘DB_PASSWORD’, ‘*****’); // …and password
define(‘DB_HOST’, ‘https://myip’); // 99% chance you won’t need to change this valueI tried these:
define(‘serveraddress:XXXX’);
define(‘serveraddress’, ‘XXXX’);
define(‘DB_serveraddress’, ‘XXXX’);
define(‘DB_PORT’, ‘XXXX’);
define(‘PORT’, ‘XXXX’);plus others , i think
define('DB_HOST', 'https://myip');
That’s the only line where you define the DB host = the server where the database is.
And “serveraddress” was just an example – how could I know where the heck your server is? When they told you the port number I assumed you know what the server name is or what its location is.
e.g.
https://you-should-know-this.org:0000
As I said: no guarantees but you may try…
(if you blog about webhosting you should know more than I do…)
and replace the 0000 with your own numbers.actually, that was the first thing i tried after my host opened the port. It did not work so i assumed that maybe i had to do it a certain way in the wordpress config file.
(Yes, I do have a hosting theamed blog, but i would consider this more of a php, mysql, wordpress problem that is a little abnormal. I have very few post that really get into those topics.)
I do not claim to know everything about web hosting, php, mysql or wordpress, Sorry if i offended you. Also, thanks for helping.
BTW: Congrats on your two years here!
This should definitely work:
define('DB_HOST', 'https://themysqlservername:9999');
Where
9999
is the post number on which the database server accepts connections on. Obviously, change the first bit to reflect your database server name.Thanks piz_dim, that did not work either. I know i made some changes to my server a couple months ago for security, so i am not sure if this is the reason i am having this problem or not.
my host just told me that they would open the port….
I know i made some changes to my server a couple months ago…
Hmmm. Which one is the correct statement?
moshu, what are you talking about?
They are both true statements
I have a dedicated server, that i made some changed to the defult config that made it more secure.
Becuase podz said in the first reply that a host does not normally allow a site outside the network access a servers sql. I called to see if the company that has my server had any problem with that and they said it was no problem. Probubly because it is my dedicated server.
So, I am really not sure what you are taking about? And, why you have taken this position to my call for assistance to the wordpress support?
Have i posted something to offend you or for you to wonder if something i said were true?
As i said in a post above, i do not claim to be any expert in this, but i do do all my own server admin stuff. If i don’t know something i ask and read then try to figure things out for myself.
I could not get this to work so i posted here. I tried everything i could think of and what was suggested here.
I mentioned that i did make some config changes for security because that is the only reason i can come up with as to why it is not working.
What reason do i have to make untrue statments? What would i have to gain?
Again i don’t get why you are making these statements
I don’t know of a host that will let a database be accessed from outside their own system. You need to talk to them first.
Hmm, mine does and I didn’t think it was that unique. There’s an area for me in CPanel where I can set up allowed IPs or IP ranges. Hmm.
what’s with this “https://” in the DB_HOST definition?
That doesn’t seem right at all. You shouldn’t be telling it to communicate via http, you should just have the db server’s ip address, and the port if the listening port on the db server is nonstandard.
So, if the db server is “db.myhost.net” and the port is 9999, you’d say
define('DB_HOST', 'db.myhost.net:9999');
There’s a trick though. On the db side, you need to grant permission for that user@host to access the database. Try using the mysql command line client to establish a connection, to see if you can (example: mysql -u username -p -P 9999 -h db.myhost.net databasename). See if it works.
If you can connect that way, then you should be fine, just keep everything set appropriately.
If you can’t, then that’s your problem. You might need to re-run your grant command. Something like:
"GRANT ALL PRIVILEGES on databasename.* TO 'username'@'%' IDENTIFIED BY 'password';
(% for the host is a wildcard, matching any host)
Oh, and by default, mysql’s config binds it to loopback ports — that is, only allows localhost to connect. The vast majority of deployments are set up that way. Shared hosting environments often host multiple databases on a single server, and allow access to either addresses in their own address space, or to the world at large. Neither configuration is particularly unusual.
And if the port happens to be 3306, you don’t need to muck around with specifying it, since that’s the default port.
Thanks complich8, I’ll work on this more… Your post has helped me understand a little better how it should be.
The grant command was done by my hosts admin so i am not sure exactly what they did and i was thinking that could be part of the problem. I had them do it because it was something i was unfamiliar with.
It looks like in your grant command example, i need to specify the database that will be accessed. My host did not ask me for that info when they ran the command.
Again Thanks, I’ll take your advise and work on it more.
Complich8: thanks for the correction. The “https://” part is wrong. My apologies for giving anyone a “bum steer”, a little careless with my copy/paste in this instance.
- The topic ‘mysql on different server’ is closed to new replies.