LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-14-2013, 06:21 PM   #1
linutzy
LQ Newbie
 
Registered: Jul 2005
Posts: 18

Rep: Reputation: 0
MySQL and Apache


I have two physical machines. I would like to connect Apache on one machine to MySql on the other. Do I need to do anything else other then add the IP address of the Apache box to the configs of the Mysql box? Or am I doing something wrong
 
Old 11-14-2013, 06:27 PM   #2
Habitual
LQ Addict
 
Registered: Jan 2011
Location: Youngstown, Ohio
Distribution: LM17.1/Xfce4.11.8
Posts: 7,182
Blog Entries: 10

Rep: Reputation: 1980Reputation: 1980Reputation: 1980Reputation: 1980Reputation: 1980Reputation: 1980Reputation: 1980Reputation: 1980Reputation: 1980Reputation: 1980Reputation: 1980
Quote:
Originally Posted by linutzy View Post
Do I need to do anything else other then add the IP address of the Apache box to the configs of the Mysql box? Or am I doing something wrong
what configs are you referring to?
Something in the middle of Apache and MySQL?
 
Old 11-14-2013, 06:34 PM   #3
linutzy
LQ Newbie
 
Registered: Jul 2005
Posts: 18

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by Habitual View Post
what configs are you referring to?
Something in the middle of Apache and MySQL?
I essentially just want my apache machine (box1) to connect to my mysql machine (box2) . So every time my site is accessed from box1, which will be public facing, if a database is used on the site (Wordpress), box2 handles it. I essentially need both machines to communicate with each other.
 
Old 11-14-2013, 06:55 PM   #4
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=14, FreeBSD_10{.0|.1|.2}
Posts: 3,884
Blog Entries: 1

Rep: Reputation: 2005Reputation: 2005Reputation: 2005Reputation: 2005Reputation: 2005Reputation: 2005Reputation: 2005Reputation: 2005Reputation: 2005Reputation: 2005Reputation: 2005
Quote:
Originally Posted by linutzy View Post
I essentially just want my apache machine (box1) to connect to my mysql machine (box2) . So every time my site is accessed from box1, which will be public facing, if a database is used on the site (Wordpress), box2 handles it. I essentially need both machines to communicate with each other.
it is more a matter of configuring the MySQL box to accept network connections, then configuring the WordPress (or other) DB to use that machine for access.

The examples I give here are for Slackware but will be very similar for other distros...

First, on the MySQL machine, make sure the server is not started with --skip-networking option. This may either be added in the MySQL start script, like /etc/rc.d/rc.mysqld, OR it might be found in /etc/my.cnf. If it is found, comment it out and restart the MySQL server, however that is done on your machine (/etc/rc.d/rc.mysqld restart for Slackware).

Next, you will need to grant access rights to a user from the Apache machine. From the shell as root (or MySQL admin user)

Code:
mysql -pxxxxxxxx (start the mysql client)

GRANT ALL ON DB.* TO apache-user@apache-host IDENTIFIED BY 'XXXXXXXX';
Where xxxxxxxx and XXXXXXXX are the respective user passwords, DB is the database name.

'apache-user' is the name used from the Apache machine (not necessarily a username on that machine) and apache-host is the host name or IP address of the Apache machine.

Finally, on the Apache machine in the WordPress or other config, set the equivalent of:

Code:
dbUser=apache-user
dbPass=XXXXXXXX
dbHost=mysql-host
dbName=DB
That should do it.

Your distro may provide different ways of restarting the mysqld daemon, and the hosts of course must be visible to each other on the network wither by name or address, but these are the basic requirements.

Last edited by astrogeek; 11-14-2013 at 07:10 PM. Reason: typos, hilighting, clarity
 
Old 11-14-2013, 07:08 PM   #5
linutzy
LQ Newbie
 
Registered: Jul 2005
Posts: 18

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by astrogeek View Post
From the shell as root (or MySQL admin user)
When you say root here (as you can see I'm not very good at this) do you mean Linux Root or Mysql Root? I'm not sure if this http://dev.mysql.com/doc/refman/5.5/...rmissions.html and the Linux Root are the same. Sorry :-(
 
Old 11-14-2013, 07:16 PM   #6
Habitual
LQ Addict
 
Registered: Jan 2011
Location: Youngstown, Ohio
Distribution: LM17.1/Xfce4.11.8
Posts: 7,182
Blog Entries: 10

Rep: Reputation: 1980Reputation: 1980Reputation: 1980Reputation: 1980Reputation: 1980Reputation: 1980Reputation: 1980Reputation: 1980Reputation: 1980Reputation: 1980Reputation: 1980
Quote:
Originally Posted by astrogeek View Post
From the shell as root (or MySQL admin user)
mysql -uroot -p <enter>
and enter the root password and you're golden.

Quote:
Originally Posted by astrogeek View Post
GRANT ALL ON DB.* TO apache-user@apache-host IDENTIFIED BY 'XXXXXXXX';
apache-user can be ANY name you like for the connection/userid but
apache-host should be somethling like 'ipa.ddr.ess' for explict permissions from a single host.

another example:
Code:
GRANT ALL ON DB.* TO fredflintstone@'192.168.1.5' IDENTIFIED BY 'betty rubble is HOT';
where 192.168.1.5 is the IP of the apache host.

Hope that helps.
 
Old 11-14-2013, 07:18 PM   #7
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=14, FreeBSD_10{.0|.1|.2}
Posts: 3,884
Blog Entries: 1

Rep: Reputation: 2005Reputation: 2005Reputation: 2005Reputation: 2005Reputation: 2005Reputation: 2005Reputation: 2005Reputation: 2005Reputation: 2005Reputation: 2005Reputation: 2005
Quote:
Originally Posted by linutzy View Post
When you say root here (as you can see I'm not very good at this) do you mean Linux Root or Mysql Root? I'm not sure if this http://dev.mysql.com/doc/refman/5.5/...rmissions.html and the Linux Root are the same. Sorry :-(
Usually Linux root, but actually any MySQL admin user with GRANT privileges, that is why I said:
Code:
From the shell as root (or MySQL admin user)
Other than restarting the mysqld daemon which will generally require Linux root privs, everytihng else is in MySQL context.

By The way, what distro is this on?
 
Old 11-14-2013, 07:20 PM   #8
linutzy
LQ Newbie
 
Registered: Jul 2005
Posts: 18

Original Poster
Rep: Reputation: 0
I don't know a fraction of what you guys know, but I really like debian and mint...I will try this when I get home. I always thought root for mysql was different then root from a fresh unix/linux install. I thought mysql root was something that was created after...wow



I am using debian btw...but have another machine that I'm ready to try LFS on. I have a bit going on.

Last edited by linutzy; 11-14-2013 at 07:22 PM.
 
Old 11-14-2013, 07:28 PM   #9
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=14, FreeBSD_10{.0|.1|.2}
Posts: 3,884
Blog Entries: 1

Rep: Reputation: 2005Reputation: 2005Reputation: 2005Reputation: 2005Reputation: 2005Reputation: 2005Reputation: 2005Reputation: 2005Reputation: 2005Reputation: 2005Reputation: 2005
Quote:
Originally Posted by linutzy View Post
I don't know a fraction of what you guys know, but I really like debian and mint...I will try this when I get home. I always thought root for mysql was different then root from a fresh unix/linux install. I thought mysql root was something that was created after...wow



I am using debian btw...but have another machine that I'm ready to try LFS on. I have a bit going on.
You are correct, a MySQL user named 'root' is not the same as the Linux root user. But when you start the mysql client without specifying a user, the Linux login user is assumed. So most installations by default create a MySQL user named 'root' with full privs as a convenience, just so that the system root user is kind of automatically the MySQL super-admin user too. But in reality there is zero connection between the system root and any MySQL user that also happens to be named root.

Last edited by astrogeek; 11-14-2013 at 07:30 PM.
 
Old 11-15-2013, 04:55 AM   #10
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,240

Rep: Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324
Re Linux root & MySQL root; its true they are totally unrelated.
I always think they should have called it dba instead...
 
Old 11-15-2013, 07:09 AM   #11
zhjim
Senior Member
 
Registered: Oct 2004
Distribution: Debian Squeeze x86_64
Posts: 1,748
Blog Entries: 11

Rep: Reputation: 233Reputation: 233Reputation: 233
On debian you have to change /etc/mysql/my.cnf to have the server listen on an ip address that is reachable from the network. Find the line with bind-address and change the value to the ip of the server. Afterwards restart mysql

Code:
# get ip
ip addr
# edit mysql config
editor /etc/mysql/my.cnf
# restart mysql
service mysql restart
 
  


Reply

Tags
apache, debian, mysql, server


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Apache against Mysql Icantprintinlinux Linux - Security 3 11-09-2007 06:48 PM
apache and MySQL phantom_cyph Linux - Software 2 10-23-2007 10:01 PM
Apache Mysql Php: mysql with php doesn't work breakerfall Linux - Networking 6 12-27-2003 09:59 PM
apache,mysql ? johnyy Linux - Software 9 08-13-2003 02:17 PM
accessing mysql from apache/mysql vher Linux - Newbie 1 01-17-2003 03:38 PM


All times are GMT -5. The time now is 10:45 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration