Local and Remote Users MySQL supports both local and remote users. A local user connects to the server and accesses the databases from the same computer that the MySQL server is running on ( localhost ). All our examples so far have been fora local user. In contrast, a remote user connects to the server and accesses the databases from another computer. For each application, you must decide how the database will be used and apply the most restrictive set of access privileges needed to get the job done. There are performance as well as security issues to be considered when doing this. MySQL actually treats local connections differently if the client is local, the connection is made internally through a Unix socket (for Linux and Mac OS Xor through a named pipe (for Windows. This is generally much faster than the TCP/IP network connection used for remote access. You should be careful not to give remote access to the database when you can avoid it. Consider the case where three different managers need to see how many items of each title there are in stock. You could give each manager an account on the MySQL server and allow remote access so that they can connect to the database from their own computers and run queries to view the data. This is shown in Figure 9-2. Since there area limited number of queries needed to generate standard reports for the managers, you could instead create a password-protected dynamic web page that displays the output of the necessary reporting queries managers would still access the reports from their own computers, but through a web browser rather than a MySQL client. This approach has several security benefits you don’t have to give database server accounts to other users, you don’t have to allow remote access, only your own client programs can run queries on the database server, and only the limited set of queries supported by your client program will be executed. Figure 9-3 shows how this could be configured. User with database client software Remote access to database server User with database client software Remote access to database server User with database client software Remote access to database server Host running database server Database server software Figure 9-2. Database server, with managers computers configured for remote access to the database server
Share with your friends: |