root@localhost

Discussion in 'Web Design and Development' started by Keytachi, Apr 29, 2007.

  1. Keytachi macrumors regular

    Joined:
    Sep 14, 2006
    #1
    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
     
  2. Eraserhead macrumors G4

    Eraserhead

    Joined:
    Nov 3, 2005
    Location:
    UK
    #2
    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.
     
  3. Keytachi thread starter macrumors regular

    Joined:
    Sep 14, 2006
    #3
    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"?
     
  4. Eraserhead macrumors G4

    Eraserhead

    Joined:
    Nov 3, 2005
    Location:
    UK
    #4
    I don't know, I'd change the title to access Database remotely if you want some answers ;).
     
  5. grapes911 Moderator emeritus

    grapes911

    Joined:
    Jul 28, 2003
    Location:
    Citizens Bank Park
    #5
    I'm not following at all, so many others probably aren't either. What exactly are you trying to do?
     
  6. mkrishnan Moderator emeritus

    mkrishnan

    Joined:
    Jan 9, 2004
    Location:
    Grand Rapids, MI, USA
    #6
    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.
     
  7. Keytachi thread starter macrumors regular

    Joined:
    Sep 14, 2006
    #7
    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
     
  8. grapes911 Moderator emeritus

    grapes911

    Joined:
    Jul 28, 2003
    Location:
    Citizens Bank Park
    #8
    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.
     
  9. Keytachi thread starter macrumors regular

    Joined:
    Sep 14, 2006
    #9
    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).
     
  10. mkrishnan Moderator emeritus

    mkrishnan

    Joined:
    Jan 9, 2004
    Location:
    Grand Rapids, MI, USA
    #10
    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.
     
  11. Keytachi thread starter macrumors regular

    Joined:
    Sep 14, 2006
    #11
    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
     
  12. mkrishnan Moderator emeritus

    mkrishnan

    Joined:
    Jan 9, 2004
    Location:
    Grand Rapids, MI, USA
    #12
    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.
     
  13. savar macrumors 68000

    savar

    Joined:
    Jun 6, 2003
    Location:
    District of Columbia
    #13
    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.
     
  14. Keytachi thread starter macrumors regular

    Joined:
    Sep 14, 2006
    #14
    well, i edited the conf. files in the php website, and i still have the same errors as before:
    PHP:
    Warningmysql_query() [function.mysql-query]: Access denied for user 'onloanet'@'localhost' (using passwordNOin /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 passwordNOin /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 passwordNOin /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
     
  15. Mr.Texor macrumors regular

    Joined:
    Apr 20, 2007
    #15

    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.
     
  16. Keytachi thread starter macrumors regular

    Joined:
    Sep 14, 2006
    #16
    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.
     

    Attached Files:

  17. Mr.Texor macrumors regular

    Joined:
    Apr 20, 2007
    #17
    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
     
  18. Keytachi thread starter macrumors regular

    Joined:
    Sep 14, 2006
    #18
    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:
    Warningmysql_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
     
  19. NicP macrumors 6502

    Joined:
    Jun 14, 2005
    #19
    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?
     
  20. Keytachi thread starter macrumors regular

    Joined:
    Sep 14, 2006
    #20
    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
     
  21. yellow Moderator emeritus

    yellow

    Joined:
    Oct 21, 2003
    Location:
    Portland, OR
    #21
    Code:
    yellow$ which php
    /usr/bin/php
    yellow$ which httpd
    /usr/sbin/httpd
    
     
  22. snakesqzns macrumors regular

    snakesqzns

    Joined:
    Apr 26, 2007
    #22
    To be quite frank, what you need to know you're not going to learn from this thread. Sorry, but it's true.
     
  23. savar macrumors 68000

    savar

    Joined:
    Jun 6, 2003
    Location:
    District of Columbia
    #23
    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.
     
  24. Keytachi thread starter macrumors regular

    Joined:
    Sep 14, 2006

Share This Page