Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Keytachi

macrumors regular
Original poster
Sep 14, 2006
161
0
How can I access my "root@localhost" from another computer? what does the "root" and the "localhost" mean, when trying to access my computer from another one?

Thank You

Gr.
Key
 
localhost means your own computer, root is a super high privilege mode that lets you do anything to your computer, you generally don't want to use it.
 
so, if i wanted to access a database in my computer (and edit it):

Host: "localhost" would become "my_computer_name" (what is my computer name? is it my external IP? or is it the the name found in "sharing" in the preferences?)

Username: what should i use, if "root" is to "powerful"?
 
I don't know, I'd change the title to access Database remotely if you want some answers ;).
 
You should be using an administrator account... allowing an external / noon-display user to log in as root is really dangerous.....

If I understand correctly, you are doing this in a terminal shell, right? Then you want to use ssh (or maybe rlogin) to connect to the other computer and then log in as your admin account.

As for the address or host name, I believe, if you're on a Mac on the same network, it's either the one displayed in your network settings or otherwise your intranet IP address (the one listed in network settings). If you're not on the local network, then it is the internet / extranet IP address of the router, but you must also either place the computer in the router DMZ or forward appropriate ports for SSH to that computer.
 
I'm not following at all, so many others probably aren't either. What exactly are you trying to do?

I'm trying to configure a php website, to access my database (so people can create accounts for a free service im providing). In the website source, im asked to place my database: Host, Username, Password, Port, Database Name, Database Type. I know everything, except Host and Username (wich are localhost/root in navicat).
Hope you understand what i want.

Thank you
 
Then I agree with mkrishnan, use an admin account. You should never use the root account unless you absolutely have to and know exactly what you are doing. As for the hostname, you can use localhost, your computer's name, your ip address, or 127.0.0.1. Any will work, but I recommend using localhost.
 
As for the hostname, you can use localhost, your computer's name, your ip address, or 127.0.0.1. Any will work, but I recommend using localhost.

Well, the website is being hosted by a friend. So unless i could host the website myself on my computer, (is that possible? if yes where should i put the files?) localhost is out of question (a friend is hosting the website at the moment, so i can have the name i want for the website).
 
Okay, so can you explain more carefully what the setup is? I feel like you aren't really reading the replies.

You have one computer running a webserver / PHP, and another running a SQL database of some kind, yes? Are they on the same intranet, or are they on different networks? Refer back up to my reply several ago.
 
You have one computer running a webserver / PHP, and another running a SQL database of some kind, yes? Are they on the same intranet, or are they on different networks?

They are on different networks, one is mine (the one with the SQL Database) and the other is a paid host (the one running the website).
what i need, is to configure the website (in the paid host) to be able to connect to the database (my computer).
In Navicat (SQL GUI) i have a database, with the following "stats":
Host: localhost
Username: root
Password: ********
Port: 3306

The php website, "asks" me the following: Host, Username, Password, Port.
Since the website is on a different computer than the database, "localhost" and "root" wil not work (since they will refer to the host computer localhost and root). What i need to know is, username/host names i will "tell" the host, so he can connect to my database.

Hope I have explained myself well.

Gr.
Key
 
Host: the public internet IP address of your router (and you have to make that port, 3306, available to this computer from the outside internet).

Username: the *short* username of an administrator on your computer, just as you type it into MacOS. If you don't understand what a short user name is, login with an admin account, open a terminal window, and type

whoami

(no, I'm not kidding).

Password: that user account's password for your Mac.
 
I'm trying to configure a php website, to access my database (so people can create accounts for a free service im providing). In the website source, im asked to place my database: Host, Username, Password, Port, Database Name, Database Type. I know everything, except Host and Username (wich are localhost/root in navicat).
Hope you understand what i want.

Thank you

You should create a new account and use that. Or alternatively, your database management software might have created a new account when you installed it.

It should definitely NOT be root -- if anybody finds a security flaw in your application they might be able to get root access to your machine -- i.e. they can literally do anything.
 
well, i edited the conf. files in the php website, and i still have the same errors as before:
PHP:
Warning: mysql_query() [function.mysql-query]: Access denied for user 'onloanet'@'localhost' (using password: NO) in /home2/onloanet/public_html/www/pirate-key/core/dbsimple/Mysql.php on line 152

Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home2/onloanet/public_html/www/pirate-key/core/dbsimple/Mysql.php on line 152

Warning: mysql_query() [function.mysql-query]: Access denied for user 'onloanet'@'localhost' (using password: NO) in /home2/onloanet/public_html/www/pirate-key/core/dbsimple/Mysql.php on line 152

Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home2/onloanet/public_html/www/pirate-key/core/dbsimple/Mysql.php on line 152

Warning: Invalid argument supplied for foreach() in /home2/onloanet/public_html/www/pirate-key/core/common.php on line 39

Warning: mysql_query() [function.mysql-query]: Access denied for user 'onloanet'@'localhost' (using password: NO) in /home2/onloanet/public_html/www/pirate-key/core/dbsimple/Mysql.php on line 152

Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home2/onloanet/public_html/www/pirate-key/core/dbsimple/Mysql.php on line 152
Forbidden

if any of you know php, would you mind taking a look?

P.S. How do i change my root account, to an admin account, and what wont i be able to do?

Thank you
 
They are on different networks, one is mine (the one with the SQL Database) and the other is a paid host (the one running the website).
what i need, is to configure the website (in the paid host) to be able to connect to the database (my computer).
In Navicat (SQL GUI) i have a database, with the following "stats":
Host: localhost
Username: root
Password: ********
Port: 3306

well, i edited the conf. files in the php website, and i still have the same errors as before:
PHP:
Warning: mysql_query() [function.mysql-query]: Access denied for user 'onloanet'@'localhost' (using password: NO) in /home2/onloanet/public_html/www/pirate-key/core/dbsimple/Mysql.php on line 152

Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home2/onloanet/public_html/www/pirate-key/core/dbsimple/Mysql.php on line 152

Warning: mysql_query() [function.mysql-query]: Access denied for user 'onloanet'@'localhost' (using password: NO) in /home2/onloanet/public_html/www/pirate-key/core/dbsimple/Mysql.php on line 152

Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home2/onloanet/public_html/www/pirate-key/core/dbsimple/Mysql.php on line 152

Warning: Invalid argument supplied for foreach() in /home2/onloanet/public_html/www/pirate-key/core/common.php on line 39

Warning: mysql_query() [function.mysql-query]: Access denied for user 'onloanet'@'localhost' (using password: NO) in /home2/onloanet/public_html/www/pirate-key/core/dbsimple/Mysql.php on line 152

Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home2/onloanet/public_html/www/pirate-key/core/dbsimple/Mysql.php on line 152
Forbidden

if any of you know php, would you mind taking a look?

P.S. How do i change my root account, to an admin account, and what wont i be able to do?

Thank you


you have 2 servers.. lets name them paidHost and myMac. where.. myMac is your computer and paidHost.. is well, the paid host.

when you run a php application on paidHost and you tell it that the database is on localhost, the application is going to think that the database is on its localhost not your localhost. that means that a php application running on paidHost with a sever on localhost will look on paidHost not on myMac.

To tell the application to connect to a database on myMac, you have to configure it with myMac's address, not localhost.

localhost is just an alias for "the address of the computer I'm on" or something like that.

Depending on your paid host, you might be able to have a mysql database for free. If you have one, you should use that, as having it on your computer could cause problems.

also, the error message is saying that you are not using a password.
 
Well, i understood that, but the problem is, that i configured the confg.php, and the Mysql.php files to my computer (with both the internal and external IP)
I'll attach the mysql.php file if you want to see it.
 

Attachments

  • Untitled.txt
    6.9 KB · Views: 262
if, the php application configurations is right.. then, there are several things that might be causing the problem

a) If you have a router, it might not be forwarding the request to your computer
b) The port needed is not open on your machine (firewall)
c) Host wont let you connect to an external databases....

there might be other problems.. I'm not sure tho
 
if, the php application configurations is right.. then, there are several things that might be causing the problem

a) If you have a router, it might not be forwarding the request to your computer
b) The port needed is not open on your machine (firewall)
c) Host wont let you connect to an external databases....

there might be other problems.. I'm not sure tho

a) the ports related to the DB are open
b) same as above
c) that im not sure... need to talk to my friend (the owner of the paidhost)

EDIT:
i think i found the problem, after searching the web, i came up with this (check the attached file, line 38 and 152)
then i got this error:
PHP:
Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home2/onloanet/public_html/www/pirate-key/core/dbsimple/Mysql.php on line 152

Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home2/onloanet/public_html/www/pirate-key/core/dbsimple/Mysql.php on line 152

Warning: Invalid argument supplied for foreach() in /home2/onloanet/public_html/www/pirate-key/core/common.php on line 39

Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home2/onloanet/public_html/www/pirate-key/core/dbsimple/Mysql.php on line 152
Forbidden

anyone that knows php, could try and fix that?

Thank you
 
What's the point of hosting a website on the paid host if you are going to run the database from your home computer?

Does your host not support databases?
 
well, i have the database in my computer, because it is connect to another db, and to other things (the database is not for the people to register in the website), also is easyer to manage. Unless i can host php in my home computer, i will have to use an outside host (if you know how to host php websites on a mac please tell me, it would make my life so much easier)

Thank you
 
To be quite frank, what you need to know you're not going to learn from this thread. Sorry, but it's true.
 
well, i have the database in my computer, because it is connect to another db, and to other things (the database is not for the people to register in the website), also is easyer to manage. Unless i can host php in my home computer, i will have to use an outside host (if you know how to host php websites on a mac please tell me, it would make my life so much easier)

Thank you

umm see the post two spots above, but php on a mac is easily doable. search for "MAMP" on google. you can do pretty much anything with a mac, especially when open source software is involved. don't know where you got the idea that php wouldn't run on a mac.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.