Build Your Own DatabaseDriven Website Using PHP amp;amp; MySQL [Electronic resources]

Kevin Yank

نسخه متنی -صفحه : 190/ 68
نمايش فراداده

Chapter 8: MySQL Administration

Overview

At the core of any well-designed, content-driven site is a relational database. In this book, we've used the MySQL Relational Database Management System (RDBMS) to create our database. MySQL is a popular choice among Web developers not only because it's free for non-commercial use on all platforms, but also because it's fairly simple to activate a MySQL server. As I demonstrated in "Installation", armed with proper instructions, a new user can get a MySQL server up and running in less than 30 minutes, or under 10 if you practice a little!

If all you want to do is have a MySQL server around so you can play with a few examples and experiment a little, then the initial installation process we went through in "Installation" is likely to be all you'll need. If, on the other hand, you want to set up a database backend to a real, live Website—perhaps a site upon which your company depends—then there are a few more things you'll need to learn how to do before you can rely on a MySQL server day-in and day-out.

Backups of data that's important to you or your business should be part of any Internet-based enterprise. Unfortunately, because setting up backups isn't the most interesting part of an administrator's duties, such procedures are usually arranged once out of necessity and deemed "good enough" for all applications. If your answer to "Should we back up our databases?" until now has been "It's okay; they'll be backed up along with everything else," then you really should stick around. I'll show you why a generic file backup solution is inadequate for many MySQL installations, and I'll demonstrate the "right way" to back up and restore a MySQL database.

In "Installation", we set up the MySQL server so that you could connect as root with a password you chose. This root MySQL user (which, incidentally, has nothing to do with the root user on Linux and similar systems) had read/write access to all databases and tables. In many organizations, it's necessary to create users whose access is limited to particular databases and tables, and to then restrict that access in some way (e.g. read-only access to a particular table). In this chapter, we'll learn how to facilitate such restrictions using two new MySQL commands: GRANT and REVOKE.

In some situations, such as power outages, MySQL databases can become damaged. Such damage need not always send you scrambling for your backups, however. We'll finish off our review of MySQL database administration by learning how to use the MySQL database check and repair utility to fix simple database corruptions.