Connecting to mySQL

Status
Not open for further replies.
Messages
39
Reaction score
0
Points
0
I have a quick question, im useing the following <?php code to try to connect to my newly made mysql database on my x10 hosting, I dont know what im doing wrong but what would I put for Localhost?
and dbuser, im pretty sure its visualde_visuald
it still wont connect though?
<html>
<head>
<title>Creating MySQL Database</title>
</head>
<body>
<?php
$dbhost = 'Localhost';
$dbuser = 'visualde_visuald';
$dbpass = 'testpass';
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
if(! $conn )
{
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully<br />';
$sql = 'CREATE DATABASE TUTORIALS';
$retval = mysql_query( $sql, $conn );
if(! $retval )
{
die('Could not create database: ' . mysql_error());
}
echo "Database TUTORIALS created successfully\n";
mysql_close($conn);
?>
</body>
</html>
 

TechAsh

Retired
Messages
5,853
Reaction score
7
Points
38
There is no capital letter for localhost.

If that doesn't work can you post the error message you get.
 
Messages
39
Reaction score
0
Points
0
New question!!!
I finally got access to mySQL database via this following
<?php code
<?php
$username = "visualde_visualm";
$password = "mypasswrd";
$hostname = "localhost";
$dbh = mysql_connect($hostname, $username, $password)
or die("Unable to connect to MySQL");
print "Connected to MySQL<br>";
// you're going to do lots more here soon
mysql_close($dbh);
?>

I have one question now, if I want to connect to this mySQL database via a different web host,
its on www.visualwebsitedesign.com

How would I alow my godaddy acounts to access this mySQL database?
 

GamingX

Executive Team
Messages
6,355
Reaction score
3
Points
38
As TechAsh has pointed out, the database host name just has to be 'localhost' and not 'Localhost'. Please change this.
 

Xemnas

New Member
Messages
812
Reaction score
0
Points
0
I have one question now, if I want to connect to this mySQL database via a different web host,
its on www.visualwebsitedesign.com

How would I alow my godaddy acounts to access this mySQL database?
You would need to log in to cPanel and select "Remote MySQL". From there, you'd add the URL/IP address of the remote MySQL server, then edit your scripts to use that server and see if it works. Of course, if the other host allows exporting of databases, you could instead export the remote database, remove the CREATE DATABASE line from the .sql file, create a database on your account with the same name and import the database you exported.
 
Last edited:

TechAsh

Retired
Messages
5,853
Reaction score
7
Points
38
You will need to add the IP address of this remote server to the 'Remote MySQL' section of the cPanel.

Then in the config on this remote server you will need to add the IP address for you x10Hosting account (Can be found in the left hand menu in cPanel) as the 'hostname'.

EDIT: Xemnas got there first LOL.
 
Last edited:
Messages
39
Reaction score
0
Points
0
Guys im very new to mySQL, and everything about mySQL, so I dont understand what your saying, first off you say I need to add the IP/URL address of my REMOTE mysql server, but I thought
THIS WAS MY REMOTE MYSQL SERVER?

Why would I need to add my own remote mySQL server, when THIS IS MY REMOTE MYSQL SERVER?
I added
www.visualwebsitedesigns.com under mySQL server, is that correct and if so,
WHAT Is the next step I should do in order to alow remote access, and get remote access..

YOu guys make no sense.
im not trying to clone or MOVE A data base, I want to connect to my x10 hosting mysql, FROM a godaddy www.visualwebsitedesigns.com

Sorry I need a simple and straight answer, you guys saying throw in a IP , that I have no idea even exists does not help me.
FIRST off what is this IP? where is it?

Bassically what I understand to do is..

use this
http://visualdesigns.x10hosting.com
for my db_host string in my <php right?
Edit:
I dont understand what to add for the adding a access host?
What do I put in here?
visualdesigns.x10hosting.com
then that alows me to connect via from my DB string?
 
Last edited:

TechAsh

Retired
Messages
5,853
Reaction score
7
Points
38
You need to add '208.109.181.238' to the 'Remote MySQL' Section of the cPanel.
This will allow your other server (www.visualwebsitedesigns.com) to access your X10Hosting one.

Then on www.visualwebsitedesigns.com you will need to edit the config for the MySQL server, and change the hostname to the IP address of your X10Hosting account. (Which can be found by looking at the left column of your cPanel.) Then you need to make sure the database name/username/password is all correct.

It should then work.

Is that any clearer?
 
Last edited:
Messages
39
Reaction score
0
Points
0
working on that now, where and how did you get the IP 208.109.181.238 though?
ok a few things...
Shared Ip Address 74.86.240.236
this is the only IP address i see on my Cpanel
I also got this one Last login from 75.70.254.0
so I added the IP address you said to add and then replaced mySQL config with the information,
its not able to connect though?
<?php
$username = "visualde_visualm";
$password = "newpw";
$hostname = "74.86.240.236";
$dbh = mysql_connect($hostname, $username, $password)
or die("Unable to connect to MySQL");
print "Connected to MySQL<br>";
// you're going to do lots more here soon
mysql_close($dbh);
?>

What should I do?
and for the most part im trying to register a remote access domain to go in there for the $hostname?
thats what im assuming

One last question I have is this,
how come on the remote access mySQL it says
"You can allow external web servers to access your MySQL databases by adding their domain name to the list of hosts that are able to access databases on your web site. localhost stands for the server that your site is currently on."
why would I add the address here if it says to add my other website?
 
Last edited:

MaestroFX1

Community Advocate
Community Support
Messages
1,577
Reaction score
60
Points
0
If I am getting you correctly, then to you want to have access to your database from other server. Isn't it?
Edit:
And if this is what you want, then do this:
Go to cPanel->Remote Database Access Hosts->Add your domain name/ ip
Please correct if I am not.
As always pleasure helping you
 
Last edited:
Messages
39
Reaction score
0
Points
0
Im trying to run a connectino to my mySQL database here on the .10hosting connection, from my godaddy domain www.visualwebsitedesigns.com
I wasnt able to run godaddy mySQL so, I want to wire mySQL from here to the domain I bought, alghough im thinking of switching now that I see this domain owns godaddy lmao.

So I use the IP for my www.visualwebsitedesigns.com domain for my DB_HOST right?

it still dont connect :(
 
Last edited:

MaestroFX1

Community Advocate
Community Support
Messages
1,577
Reaction score
60
Points
0
You have bought the domain(name) from godaddy ? And now you want use x10 ?
Edit:
Answer these please:
1.Current location of your database,on which server it is being hosted ?
2.Location from where you want to access it?
 
Last edited:

Russ

<b>Retired *****</b>
Messages
3,168
Reaction score
2
Points
38
GUYS.. Seriously. We don't even allow remote connections.. And, there's staff telling people how to do it? come on.
 
Status
Not open for further replies.
Top