mySQL Database. Own Website finds it, external programs not? - php

so I'm creating a website right now where I have a mySQL Database included and I'm displaying some tables of it on my website (with PHP) and it works fine.
But now I'm trying to access the database in another program (Unity) to edit my database.I get the error that the host name wasn't found. Then I tried to ping the ip (given from my hoster 1&1) via the Windows console, but not found. mySQL Workbench doesn't find it either.
I'm wondering if I have to set the database to public or something like that when I want to access it from another program. My Website can access it, probably because it's hosted on the same account.
But I only got a hostname, username, password and database name. The hostname is something like that: "db123456789.db.1and1.com". My domain is of course not this. Do I have to change the host name? On my php website script I used this host name and it works fine.
I'm kind of confused how this works and I can't find any option where I could say like "Hey DB, show yourself to the public".
Any tips? Searched the World Wide Web, but didn't found a hint. Thank you.

Related

How Can I find my database host name?

Im realy new into this php and android online database thing,So I really ask to somebody to fix my problem.
Im using mysqli_connection and I need my host name for this query ;
$con = mysqli_connect($host,$user,$password,$db);
But the problem is I dont know what is my host my phpMyAdmin site look like this
https://hike.veridyen.com:2083/
and I'm entering my site from this url;
http://dobo.us/atakan/
so what is my host name please ?
If you are using a shared hosting it should be located as follow:
After creating your database, you can find its details, including its
hostname, in your control panel.
Log in to your GoDaddy account.
Click Web Hosting.
Next to the hosting account you want to use, click Manage.
In the Databases area, click MySQL or MSSQL depending on the database type for which you want the host name.
From your list of databases, click Actions next to the database you want to use, and then click Details.
Your database's details displays including its username, host name,
and a link to reset its password.
Instructions above are for GoDaddy, but should give you a general sense of direction.
For SiteGround, use 'localhost'

Setting up Wordpress with Xampp on Mac

I am trying to get Wordpress working locally on my Mac. I've downloaded and installed Xampp and also the Wordpress module. But I'm not sure where to go from here, to actually get Wordpress working.
When I try to reach 127.0.0.1/wordpress/ and localhost/wordpress/ I only get the message "Error establishing a database connection".
I can reach PhpMyAdmin, enclosing a screenshot.
Screenshot from phpMyAdmin
I have no clue where to go from here. Do I need to make changes in some conf-files or something? This is the first time I'm doing this so sorry for noob questions, I'm not really a programmer, just want to be able to build my Wordpress sites locally... :)
You need to create a database within PHPMyAdmin, and then configure wp-config.php with the database information. By default, you may only have a file called wp-config-sample.php. Rename the file, and remove -sample from the file name.
The host name will be "localhost", since the database is locally hosted.
The username will be the username to phpmyadmin, and the password will be the password for that account.
The database name will be the database name that you chose.
The prefix can be left alone, as the default is just fine. :)

Accessing server through web browser using ip address redirects to localhost

I'm using prestashop to set up an e-commerce website on my cloud server. I was able to successfully install it on the server and it works fine on the server locally, i.e. if I look at the website using localhost on the server. However when I try to access it from a different machine it won't work because, it gets redirected to localhost/index.php? I'm not sure what could be wrong or even where to start looking... any help would be appreciated. Only thing I could think of was the index.php file. It has following 2 lines of code and is generated by prestashop.
I apologize if this is not the correct SO website, as I wasn't sure what the issue could be related to.
Thank you.
When moving an CMS to another domain problems like this often occurs. Most CMS saves the domain they should run on in configuration file oder database. If there is an request for another domain they are sending an redirect (HTTP state code 302) back. I think problem here is that this one is set to localhost.
A short search on google pointed out that prestashop saves a domain name configuration in a mySQL database. Since petrashop 1.5 it should be in a table called PREFIX_shop_url. Before it was saved in PREFIX_configuration as PREFIX_shop_url. But I didn't tested on my own. You should have a look on your own and change the value in database to your new domain.
You could use mysql command line client to connect to database and change the value. If your are not so familiar with SQL you could also use a GUI like phpmyadmin.

Problems connecting to a remote server and performing a simple db query

I have set up a website with basic HTML/CSS files and would like to take that one step further and implement a database with some PHP to perform simple queries and whatnot.
My problem arose when I noticed while setting up the database and creating the PHP files that connect to the database (on my local machine), I used 'localhost' as an argument for mysql_connect. When I then went to drag and drop my newly created HTML/PHP files along with my database into FileZilla to upload the pages onto my remote server, there was a problem connecting to the database. I have a feeling that it is unhappy with the whole 'localhost' notion - yet I don't know what to change it to.
Currently, I am using this line of PHP code to connect to my remote database (which is all located in FileZilla-land).
$link = mysql_connect('localhost','Tommy','pass')
Also, as another quick question: does my remote server have its own phpMyAdmin page? And if so... how would one go about finding it? =D
I appreciate anyone who is able to assist me in my endeavors.
Thank you!!
Log on to your database server, check the details and obtain the correct server information such as server, username and password.
Once you change the server details you shoudl be ready to rock n roll. Edit post with the host name/server name and we may be able to find it for you.
You'll have a phpMyAdmin page where you're hosting the site. Check the membership area or cPanel.
You are right in that 'localhost' in mysql_connect needs to be different. 'localhost' is a textual representation of a loopback address AFAIK - it connects to the computer it is hosted on. As you have uploaded it to your server (a different computer) it is now trying to connect to a mysql server on the server host, instead of your home computer (which holds all the data).
To make this work you'd need to get your database onto the server you are now working from, OR depending on your home setup, point it to your local database.
Whether your host has MySQL/PHPMyAdmin available to you is another matter altogether. If they have MySQL it is probable but not definite that they have a phpmyadmin interface.
Contacting the server host will yield more information. If they have MySQL, it is probably as simple as getting the required details from them, and 'backing up' your SQL on your local server and uploading it to the new server (easily done with PHPMyAdmin)
TL;DR: The database you are trying to connect to doesn't exist on the server you're connecting from.

Mysql workbench shows wrong database instances

In order to create a new database i use Plesk Panel.
I am also using mysql workbench to administer my database instances.
The problem is that when i connect to a database in my server (via workbench) using its unique credentials (database user and passwd) i'm able to see another database instace as well that i have created for another domain in my server via plesk panel.
This second database instance has different credentials from the ones i used to login to the initial database and therefore shouldn't be visible at all.
Does anyone has a clue of how this can happen?
Both are likely linked to your account. I've used a shared hosting environment (Plesk) before where I could see all the database names on the entire server but without the correct credentials I wasn't able to access any of them or view their table structure (I found out because I didn't want others accessing my database).
I would check with your web host for more information.
You don't connect to a database, but you connect to a server. The user you are connecting with has been given privileges to access db objects according to the domain it belongs to. However, if the user you connected with is allowed to enumerate schemas then you will be able to see all defined schemas (= databases) on this server. That doesn't mean you can access it. No reason to worry unless you don't want users to see schemas they have no rights for.
Use the Server Administration section where you can list all users and see what privileges they have for which db object.
First of all thanks a lot for your time and answers.
The reason behind my problem was the actual name of the database instance I had created, which contained the word "test_".
Every database instance created with this text inside its name was visible to every database user when using mysql workbench.
I know it seems a bit strange but I resolved the issue by just changing the name of the db instance.

Categories