Announcement

Collapse
No announcement yet.

MySQL

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    MySQL

    I have 3 servers in my house:
    1. Minecraft server, Windows 2003 Server, port 25565
    2. Web and database server for a forum http://shovenose.dyndns.org/ ,Ubuntu Server 11.10, port 80
    3. THE ONE I NEED HELP WITH, internal LAN IP 10.0.1.52

    It's also running Ubuntu Server 11.10, both linux servers (2&3) use EHCP hosting control panel...
    If I type in http://10.0.1.52/phpmyadmin/ then it takes me to PHPMYADMIN properly...
    But if I'm anywhere else and type in http://shovenose.dyndns.org/phpmyadmin it takes me to the login for #2 (local IP 10.0.1.48) because port 80 forwards to that.

    So I'm wondering, can I make it so that people can type in http://shovenose.dyndns.org/phpmyadmin and they end up at the login for SERVER #3 not SERVER #2?
    It looks like phpMyAdmin uses port 80 for its interface, while the actual MySQL uses port TCP3306 (I think?)
    I'm sure I can get a database connection to 3006 to route to server 3 but how would I get the web interface for phpmyadmin to go to server 3 while all other web stuff (also port 80) goes to server #2 because I have a website/forum that needs to show up there.

    Help please! Thanks!

    #2
    Re: MySQL

    Mysql has it's own port, 3306. You can configure it to use pipes or sockets and not use a port at all but that's outside the point of this post.
    Besides the port, by default when you configure mysql with the wizard or whatever, it recommends that you configure mysql to listen only on its own "localhost", for security reasons.

    First thing you must absolutely do is rename that script folder to something else. I have several websites and can give you megabytes of logs where bots keep trying to find phpMyAdmin installations and exploit them.
    I'm using custom subdomains for my own installs, something like pma-sv1.example.org and sometimes I even reject all IPs except my home one with .htaccess rules

    You can configure phpMyAdmin to connect to whatever mysql instance you want, you have in the phpMyAdmin folder a file called config.inc.php
    There, you have a section that should look like this (this may be different, I'm not using the very latest versions, prefer to use STABLE releases):

    PHP Code:
    /*
     * Servers configuration
     */
    $i 0;

    /*
     * First server
     */
    $i++;
    /* Authentication type */
    $cfg['Servers'][$i]['auth_type'] = 'cookie';
    /* Server parameters */
    $cfg['Servers'][$i]['host'] = 'localhost';
    $cfg['Servers'][$i]['connect_type'] = 'tcp';
    $cfg['Servers'][$i]['compress'] = false;
    /* Select mysqli if your server has it */
    $cfg['Servers'][$i]['extension'] = 'mysql';
    $cfg['Servers'][$i]['AllowNoPassword'] = false
    For this computer, localhost means 127.0.0.1, so phpMyAdmin tries to connect to mySQL on 127.0.0.1, and there's no such server listening for connections there.
    So you need to replace localhost with 10.0.1.52

    Now depending on how you configured MySQL, phpMyAdmin will connect to MySQL or not.

    As I said at the start of the post, by default MySQL tends to configure itself to listen on "localhost" only, but from the computer's perspective localhost is 127.0.0.1 and 10.0.1.52 is another network card.

    So if MySQL is configured for localhost only or to use sockets/pipes, you have to tell it to listen on the 10.0.1.52 IP for connections. You need to go in my.ini and below [mysqld] you should find

    port=3306

    Add above it :

    bind-address=10.0.1.52

    to configure mysql to listen for connections on 10.0.1.52

    If you want it to listen to both localhost and the IP and all IPs you may have, try saying bind-address=0.0.0.0

    ... and restart mysql to start listening on the IP.

    let me know if you don't understand something, i'll be around for a bit more (it's 8 am here and haven't slept so far because of work).
    Last edited by mariushm; 01-13-2012, 11:58 PM.

    Comment


      #3
      Re: MySQL

      OK, I don't know how to edit that file/\.
      Thanks.
      shovenose

      Comment


        #4
        Re: MySQL

        What do you mean, you don't know WHAT to edit, or you don't know how to EDIT a file in general?

        I just said, you have to replace "localhost" with the IPs and if needed set mysql IP in my.ini - I don't know where it's located in various Linuxes...

        Comment


          #5
          Re: MySQL

          I'm running Ubuntu Server, which is command-line only.
          How/where do I edit it?

          Comment


            #6
            Re: MySQL

            http://www.howtoforge.com/faq/12_15_en.html

            There should be several text editors included - vi is one of them which is bit harder to operate, it's not "notepad", it's kind of like "the wordpad" of editors.

            Remember, it's :
            "i" to enter insert mode and type text at the cursor position, ESC to exit the insert mode
            "x" to delete the character under the cursor
            :x to save the file
            :q to quit the editor (don't forget to use :x before)

            Read the link above carefully and then you should have the my.ini on Ubuntu saved as : /etc/mysql/my.cnf

            At least that's the location this page says: https://help.ubuntu.com/11.04/serverguide/C/mysql.html

            After editing the file, sudo /etc/init.d/mysql restart in command line - sudo may not be required if you run as root.

            Comment


              #7
              Re: MySQL

              Thanks I'll try that when I get home... currently my SSH access port forwards to the other server not the one I want to be the MySQL server

              Comment

              Working...
              X