By Seyed M.M. "Saied" Tahaghoghi, Hugh E. Williams
Price: $44.99 USD
£31.99 GBP
Cover | Table of Contents | Colophon
http://www.mysql.com) claim. This modest-sized
database has introduced millions of everyday computer users and amateur
researchers to the world of powerful information systems.mysql
"
MySQL monitor" program, provided by the MySQL AB
company and available in most MySQL installations. This allows you to
connect to a MySQL server and run SQL queries. Other simple clients are
included in a typical installation; for example, the mysqladmin program is a client that allows you
to perform various server administration tasks.http://httpd.apache.org). Apache has a long
history of reliable service and has been the most popular web server in
the world for over 10 years. The Apache web server—or "HTTP
server"— project is managed by the Apache Foundation (http://www.apache.org). Although the web server
and MySQL server are separate programs and can run on separate computers,
it’s common to find small- to medium-scale implementations that have both
running on a single computer. In Chapters through , we’ll explore how the Perl programming
language can be used to build command-line and web interfaces to the MySQL
server.http://www.learningmysql.com, which contains the
sample databases, datafiles, and program code. We recommend you make good
use of the web site while you read this book.
konsole,
rxvt, or
xterm; these are often listed in the main menu
under the System or System Tools group, and may be simply labeled
Terminal. To access the shell under Mac OS X, open a terminal window by double-clicking on the
Terminal icon in the Utilities folder under the Applications
group.
while under Mac OS X, you’ll see something like this:
This
shell prompt indicates what user account you’re
logged in under, what computer you’re logged in to, and what directory
you’re working from. You’ll generally be first logged in as an ordinary
user (we’ve shown the user adam here)
on the computer (edenpico, gvim, vim, emacs, joe, kate, gedit, and xedit. You can often find these listed
under the Editors group in the main menu of most Linux distributions. If you’re curious, you can also
type the command apropos "text
editor" at the shell to see a list of programs that have
the phrase "text editor" in their description.gvim, or commercial editors such as
EditPad and TextPad.pico, vim, or emacs, configure the TextEdit program to
behave as a text editor, or install and use other editors such as
BBEdit or Smultron.localhost). We won’t describe how to set up the
MySQL server on one computer and the web server on a different computer;
it shouldn’t be too hard to modify our instructions to do this. If you
modify any of the default settings, you’ll need to remember to specify
them where necessary.C: disk; we’ll explain how and when to
change your working directory. When we show only the Linux or Mac OS X
prompt as below:
or the Windows Command Prompt as:
the working disk and
directory are unimportant, or you will be in the appropriate location
after following the steps we describe.#) as the
prompt:
you will need to type in the commands as the superuser. For a Linux or Mac
OS X system, this means you should log in as the system superuser by
typing su -, or use the sudo keyword before the command. For a Windows
system, you must be logged in with a system account that has administrator
privileges./) with the backslash character (\). For example, you may see an example starting
the MySQL monitor program (mysql) from
the bin subdirectory as follows:
bin/mysql
On Windows, you’d type
bin\mysql at the Windows Command
Prompt. After this chapter, we’ll mostly omit the path to programs and
assume that you’ll call them using the appropriate path described for your
installation in this chapter.http://dev.mysql.com/downloads. shows what this
page looks like.rpm program. The name is a
vestige of the program’s origins as the Red Hat Package Manager.
However, many Linux distributions other than Red Hat use RPMs for
managing software installation; these include Fedora,
Mandriva/Mandrake, and SUSE. The MySQL AB company also provides
files for download in the format used by Debian-based distributions
but recommends that the apt-get
method be used instead; we describe the recommended approach in this
chapter.XAMPP integrated package.sudo
command.
/usr/local/mysql that points to this
installation directory. For example, the files could be installed in the
/usr/local/mysql-5.0.22 directory, and the /usr/local/mysql link set to point to this
directory.ssh or telnet
access to the server to run the MySQL client, or whether you can use only
web clients such as phpMyAdmin; using web clients is easy, but you could
soon find them tedious to use over extended periods of time. On a
different note, don’t forget to also check how much data transfer is
included when comparing costs of alternative web hosting deals. If your
site becomes popular, it could end up costing you a lot of money!http://bugs.mysql.com web site. You can
use this web site to view the bug reports for your MySQL version
and determine whether any are likely to affect your
operations.SELECT queries) were not possible in
MySQL before version 4.1; neither were multiple concurrent
character sets.MYSQL
named pipe if the server was started with the
enable-named-pipe option. In other cases, clients
send their requests through a TCP/IP network connection. Using a named
pipe can actually be slower than using TCP/IP.
skip-networking option. For a server running on
Windows, remember to enable the
enable-named-pipe option at the same time;
otherwise you won’t be able to connect to the server.
wget,
yum, and
apt-get programs, you can declare the HTTP and
FTP proxy settings as shown below:
export http_proxy=http://
proxy_username:password@server_name:port
export ftp_proxy=http://
proxy_username:password@server_name:port
For example, you might type:
export http_proxy=http://
adam:password@proxy.mycompany.com:8080
export ftp_proxy=http://
adam:password@proxy.mycompany.com:8080
Your Internet service provider or company network administrator can
provide the proxy settings that you should use. If for some reason the
rpm command does not work through the
proxy, you can download the file yourself using a browser or with
wget. You can then install this
downloaded file manually using the rpm
--upgrade or dpkg
--install commands.
mysqld_safe and
mysqld-nt.exemysqld_safe and mysqladmin. Compiled programs contain
binary (0 and 1) code, rather than human-readable text, hence the
name of this directory. However, you’ll probably find some
human-readable script files in this directory too.http://localhost. If your browser reports that it
can’t open this page, you can try to start the server by using the
appropriate XAMPP startup command, or the perl) is
installed on your system. For Linux, we’ll use the instance of Perl that
comes with the distribution; to find where this is located, use the
which command:
which perl
/usr/bin/perl In this example, the Perl interpreter is the file
/usr/bin/perl.
perl --version
On a Windows or Mac OS X system, the XAMPP Perl interpreter is not in
the system path, so you should specify the full path on a Windows system
as: http://dev.mysql.com/doc, although we recommend
you explore these after you’ve finished reading this book.http://forums.mysql.com and the lists page at
http://lists.mysql.com.http://forge.mysql.com). In
particular, look at the collection of (mostly user-contributed)
documentation by following the "Wiki" link near the top of
the page. Don’t worry if it all seems overwhelming at first; you’ll be
able to make sense of most of it by the time you reach the end of this
book!http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/ntcmds_o.mspx.
Much of this information applies to Vista too.http://www.apachefriends.org/en).
http://httpd.apache.org.mysql and is found in a directory with the other
MySQL programs. The exact location depends on your operating system and
how you chose to install MySQL; we considered some of these in ,” in Chapter 2.root user) by typing this from the
command line:
mysql --user=root
If you
followed our instructions in , the MySQL
root account is protected by the
password you chose earlier, and so you’ll get a message saying that you’ve
been denied access to the server. If your server has a password, you
should specify the password as follows:
mysql --user=root --password=
the_mysql_root_passwordmysql and is found in a directory with the other
MySQL programs. The exact location depends on your operating system and
how you chose to install MySQL; we considered some of these in ,” in Chapter 2.root user) by typing this from the
command line:
mysql --user=root
If you
followed our instructions in , the MySQL
root account is protected by the
password you chose earlier, and so you’ll get a message saying that you’ve
been denied access to the server. If your server has a password, you
should specify the password as follows:
mysql --user=root --password=
the_mysql_root_password
mysql executable file as discussed in
.”mysql. For example, you might type:
mysql \
--socket=server_socket \
--user=root \
--password=
the_mysql_root_password
If you’re trying to connect to a MySQL server on a different computer or a
nonstandard port, you should specify these when starting the
monitor: $mysql \
--host=server_host_name \
--port=server_port \
--user=root \
--password=
the_mysql_root_password
We list a few more options to the monitor program at the end of this
chapter.SELECT or FROM. We also show the MySQL monitor’s
proprietary SQL commands—such as USE—in
uppercase. We always enter database components—such as database, table,
and column names—in lowercase. This makes our SQL more readable and easier
to foll