7.9. Creating Databases and Accounts on a MySQL ServerMySQL is an open source database system that has become very popular due to its high performance, lightweight design, and open source license. Many software packages, including web applications such as the Serendipity blog software (http://www.s9y.org/), use MySQL to store data. In order to use these programs, you will need to create a MySQL database and access account. 7.9.1. How Do I Do That?First, you'll need to select names for your database and access account; for this example, let's use chrisblog for the database name and chris for the access account. Both names should start with a letter, contain no spaces, and be composed from characters that can be used in filenames. To create the database and account, use the mysql monitor program: # mysql Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 to server version: 5.0.18 Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> create database chrisblog; Query OK, 1 row affected (0.01 sec) mysql> grant all privileges on chrisblog.* to 'chris'@'localhost' identified by 'SecretPassword'; Query OK, 0 rows affected (0.00 sec) mysql> quit Bye
You can then enter the database, access account, and password information into the configuration of whatever software will use MySQL.
For example, to install Serendipity:
Figure 7-23. Serendipity Installation verification page
Figure 7-24. Serendipity Installation pageFigure 7-25. Serendipity Installation confirmation pageFigure 7-26. Serendipity blog front page7.9.2. How Does It Work?MySQL is a Structured Query Language (SQL) database server. It provides rapid access to large sets of structured data, such as customer lists, sports scores, student marks, product catalogs, blog comments, or event schedules. The MySQL database runs as a server daemon named mysqld, and many different types of software can connect to the server to access data. Connections to the database server are made through the network socket /var/lib/mysql/mysql.sock (local connections) or on the TCP port 3306 (remote connections). If the MySQL server is running on the same machine as your application, you should leave port 3306 closed in your firewall configuration, but you must open it if you separate the MySQL server and the application onto different machines (which you might do for performance reasons if you're using the database heavily). The mysql monitor command is a very simple command-line interface to the MySQL server. It permits you to enter commands to the server and to see the results of those commands on your screen. MySQL data is stored in /var/lib/mysql; each database is stored in a separate subdirectory. 7.9.3. What About...7.9.3.1. ...creating my own scripts and programs that access MySQL data?Most scripting and programming languages have modules to access MySQL data. For example, you can use the database driver (DBD) module DBD::mysql to access the basic database interface (DBI) abstraction layer to work with databases in Perl. For details on writing software that accesses a MySQL database, see Chapter 22 in the MySQL documentation (http://dev.mysql.com/doc/refman/5.0/en/apis.html). 7.9.4. Where Can I Learn More?
|