Koozali.org: home of the SME Server

MySQL - localhost

Offline xviper

  • *
  • 6
  • +0/-0
MySQL - localhost
« on: October 09, 2007, 11:18:24 AM »
Hello

I have two boxes and I want to use one as a database and the other for the website.

Can you tell me how I could / or which files to change in order to address one as the "IP number" instead of "localhost"

Thanks

.

Offline cactus

  • *
  • 4,880
  • +3/-0
    • http://www.snetram.nl
Re: MySQL - localhost
« Reply #1 on: October 09, 2007, 04:27:32 PM »
Hello

I have two boxes and I want to use one as a database and the other for the website.

Can you tell me how I could / or which files to change in order to address one as the "IP number" instead of "localhost"

Thanks

.
If they are SME Servers you should look in the MySQL section of the manual in the wiki, this should help you get started. Default allows mysql access only from localhost, you will have to disable the localnetworking only option for other hosts to connect to the mysql server.
Be careful whose advice you buy, but be patient with those who supply it. Advice is a form of nostalgia, dispensing it is a way of fishing the past from the disposal, wiping it off, painting over the ugly parts and recycling it for more than its worth ~ Baz Luhrmann - Everybody's Free (To Wear Sunscreen)

Offline xviper

  • *
  • 6
  • +0/-0
Re: MySQL - localhost
« Reply #2 on: October 10, 2007, 01:29:35 PM »
Hi Cactus

Thank you for your reply, I have tried this;

config setprop mysqld LocalNetworkingOnly no
 expand-template /etc/my.cnf
 /etc/rc.d/init.d/mysqld restart


and

config set mysqld service access public status enabled TCPPort 3306
 signal-event remoteaccess-update
 signal-event reboot


However, I am still haveing a problem connecting from another box. Also when I login to phpmyadmin I see it's shows "localhost" and not the IP Number.

Do you know off hand any other files I could edit?

Thanks

Damien

Offline cactus

  • *
  • 4,880
  • +3/-0
    • http://www.snetram.nl
Re: MySQL - localhost
« Reply #3 on: October 10, 2007, 08:58:29 PM »
Thank you for your reply, I have tried this;

config setprop mysqld LocalNetworkingOnly no
 expand-template /etc/my.cnf
 /etc/rc.d/init.d/mysqld restart


and

config set mysqld service access public status enabled TCPPort 3306
 signal-event remoteaccess-update
 signal-event reboot

Above commands should be fine...
However, I am still haveing a problem connecting from another box.
...but you probably need to configure a user that has access from the other machine as well, as the root user is only allowed to login from the localhost. Information on how to create users is at the end of the MySQL section of the wiki as well as in the MySQL User Account Management section of the MySQL manual.
Also when I login to phpmyadmin I see it's shows "localhost" and not the IP Number.
That should be fine to as long as phpmyadmin is running on the same server as the MySQL database is. Localhost is just an alias for the local loopback to your server, also known as 127.0.0.1
Be careful whose advice you buy, but be patient with those who supply it. Advice is a form of nostalgia, dispensing it is a way of fishing the past from the disposal, wiping it off, painting over the ugly parts and recycling it for more than its worth ~ Baz Luhrmann - Everybody's Free (To Wear Sunscreen)

Offline CharlieBrady

  • *
  • 6,918
  • +3/-0
Re: MySQL - localhost
« Reply #4 on: October 11, 2007, 12:50:08 AM »
I have two boxes and I want to use one as a database and the other for the website.

Can you tell me how I could / or which files to change in order to address one as the "IP number" instead of "localhost"

You are asking the wrong question. What you need to ask are:
  • how do I configure mysql on an SME server to allow access from another server?
  • how do I configure my website software to use a database on another server?

The first question has been answered here. The second will depend on what website software you plan to use, and has nothing to do with SME server.
« Last Edit: October 11, 2007, 12:52:24 AM by CharlieBrady »

Offline shell

  • ****
  • 117
  • +0/-0
Re: MySQL - localhost
« Reply #5 on: October 11, 2007, 04:06:24 AM »
sounds like a mysql privilege issue if you have already opened the access to public and opened port 3306 as in the above posts.  currently you will have created the database user using a grant statement as below from mysql prompt:

grant all privileges on [databasename].* to [dbusername]@localhost identified by '[dbpassword]';

Instead of localhost you can use wildcard (watch for security implications!!) or a specific hostname or IP address.  I believe you need to user quote marks, so it would be :

ALL HOSTS:
grant all privileges on [databasename].* to [dbusername]@"%" identified by '[dbpassword]';

SPECIFIC HOSTS
grant all privileges on [databasename].* to [dbusername]@"abc.com" identified by '[dbpassword]';

or

grant all privileges on [databasename].* to [dbusername]@"xxx.xxx.xxx.xxx" identified by '[dbpassword]';

flush privileges;

I strongly recommend the specific host option, but the "%" has come in real handy for me when testing. :-P