If the web server and the database server
are on different computers, you have to allow the web application on the web server to connect remotely to the database server, as shown in Figure 9-4. Database server software
User
with web browserUser with web browser
User with web browser
Web
database applicationLocal access to database server
Web server software
Host running database and web servers
Figure 9-3. Database server and web application the web application has local access to the databaseserver, and the managers computers interact with the database through the web applicationDatabase server software
User with web browser
User with web browser
User with web browser
Web database application
Remote access to database server
Web server software
Host running database server
Host running web server
Figure 9-4. Web application, web server, and database server configured for remote access310 | Chapter 9:Managing Users and Privileges Creating a New Remote UserIf you want to allow a user to connect to the
server from another computer, you must specify the host from which they can do so (the remote client. Suppose that you have a home network, that your machine has the private IP address 192.168.1.2, that your home domain is
invyhome.com, and that your machine is named ruttle
(that is, its complete name is ruttle.invyhome.com
). Let’s also assume that you’re running a
MySQL
server on ruttle, and that there are two other machines on the network:
toorak.invyhome.com with the IP address 192.168.1.4 and yazd.invyhome.com with IP
address Figure 9-5 illustrates this setup. Again, we differentiate between user accounts on the
MySQL server (
MySQL users or
MySQL accounts) and user accounts on the host machines (
system users or
system accounts).
Now, let’s consider the MySQL setup on ruttle
. Let’s assume you’ve previously logged into the MySQL server on ruttle as the root user and created the user hugh with the statement:
mysql>
GRANT ALL on *.* TO 'hugh'@'localhost' IDENTIFIED BY 'the_password';Query OK, 0 rows affected (0.00 sec)
If you’re logged into
your system account on ruttle, you can connect to the MySQL
server on ruttle using the following
mysql --host=localhost --user=hugh --password=the_passwordDatabase server software
Network ruttle.invyhome.com (192.168.1.2)
toorak.invyhome.com (192.168.1.4)
yazd.invyhome.com (192.168.1.6)
Figure 9-5. A simple home network with three computers, and one MySQL serverShare with your friends: