Linux 版 (精华区)

发信人: netiscpu (网中鸟~~flying), 信区: Linux
标  题: [中英]PHP/MySQL教程(2-2)安装MySQL
发信站: 紫 丁 香 (Thu Jan 13 03:24:13 2000), 转信


[中英]PHP/MySQL教程(2-2)安装MySQL
 
[原作者] Graeme Merrall
[出处] http://hotwired.lycos.com/webmonkey/programming/php/tutorials/tutorial4.html
[译者] netiscpu

PHP/MySQL Tutorial
by Graeme Merrall 

======================================================================

安装MySQL

    Installing MySQL

让我们直接进入吧,首先要获得一份软件拷贝,并且使其正常工作.这可不是一件简单
的事请,因为在获取,编译和安装软件时,会有很多选项需要选择.我们首先安装MySQL,
因为安装PHP之前需要它(译者按:这里指的是PHP/MySQL解决方案中,应该先安装MySQL,
然后安装PHP,但是独立的PHP的运行并不依赖于MySQL).

    Let's jump straight in, grab ourselves a copy of these great packages, 
    and get hacking! This isn't simple stuff. There are lots of options 
    available to you for obtaining, compiling, and installing the software. 
    Let's deal with MySQL first, as we'll need it before we get PHP going. 

MySQL的官方站点是http://www.mysql.com/,不过在全球有不计其数的镜像站点,多亏
有Internet,你可以就近获取一份MySQL的软件包.

    MySQL central is http://www.mysql.com/. As befits a program of its 
    stature, there are a zillion mirrors located all over the globe, so do
     the Internet a favor and pick the one closest to you. 

你有很多选择来获取MySQL,假如你是一个DIYer(Do-It-Yourselfer),可以下载其源码,
如果你怕麻烦,也有很多位各种平台与编译好的软件包可供下载.

    You've got plenty of choices at this point. If you're a do-it-yourselfer, 
    then grab the source code. If you're not that brave, there are some 
    precompiled binaries for other platforms already available for download. 

另外,还有一个针对Windows用户的共享版MySQL,这是一个老版本的MySQL,如果你想
得到最新版本,需要购买一个授权(License).还有一些ODBC驱动程序可以让你的应用
程序连结到MySQL.各种有关MySQL的网站上可能还有一些非常有用的东西,需要你自己
去找一找.

    In addition, there is a shareware version of MySQL for Windows users. 
    It is an older version of MySQL. If you want the latest version, you'll 
    have to purchase a license. There are also ODBC drivers that let your
    applications talk to MySQL. Various other exciting bits and pieces are 
    lurking about on the site, too, so take a look. 

已经编译好的Unix和Windows版本的MySQL安装起来非常简单,通常只要解开压缩包就可
以使用了,故无需做太多解释.这里主要从Unix平台下编译源码开始讲解.对于Windows
用户,请记住你需要运行在mysql/bin目录下的mysqld.

    The precompiled Unix versions and the Windows version are as simple as 
    unpacking and going, and they don't require much explanation. So let's 
    compile from the source code. Windows users, please keep in mind that 
    you need to run mysqld in the mysql/bin directory. 

将压缩文件下载到你的源码目录,并且用gzip和tar解开,一个比较快的方法如下:

gunzip < mysql-xxxx.tar.gz | tar xvf - 

其中xxxx用你的MySQL的版本号替换,这个命令将创建一个mysql-xxxx目录,其中包含
所有的源代码文件.输入"cd myslq-xxx"命令,进入该目录,认真阅读不同的README和
INSTALL文件,在你遇到问题是,这些知识将非常有用.

    Download the compressed file into your source directory and uncompress 
    and untar it using gzip and tar.The fast way of doing this is to type: 

        gunzip < mysql-xxxx.tar.gz | tar xvf - 

    The xxxx is where you put the version number. This will create a 
    directory called mysql-xxxx, which contains all the source files. Move 
    to that directory by typing cd mysql-xxxx and check out the various 
    README and INSTALL files. They're lifesavers in sticky situations. 

MySQL带有一个易用的配置脚本,只要简单地输入"./configure",它自己就能将一切
配置工作做完,如果你需要做一些定制工作,输入"./configure --help",就会得到可
供选择的一个选项列表,比如,你要在一台内存很少的机器上编译,就可以加上
"--with-low-memory"的选项,我喜欢将MySQL安装在一个特定的目录,而不是随便一
个目录,所以我会加上一个安装目标路径的选项"--prefix".

    MySQL comes with a handy configuration script. Simply type ./configure 
    and let things take care of themselves. If you need to specify what 
    happens and where, typing ./configure --help gives you a list of
    options to choose from. For example, if you're compiling on a machine 
    with little memory, you can opt for the --with-low-memory flag. I like 
    MySQL to install in one handy directory tree rather then in various 
    locations    on my machine, so I specify an install location with the 
    --prefix flag. 

你还可以指定许多其它选项,比如需要编译某一部分以及跳过另一部分,这里假定我们
将MySQL所有部分都安装在我们的服务器上"/usr/local/mysql"目录,所以需要输入命
令"./configure --prefix=/usr/local/mysql".

    You can also specify lots of other options, such as what to compile 
    and what to skip. Let's assume that we want everything under 
    /usr/local/mysql on our server. This means we'd type 
    ./configure --prefix=/usr/local/mysql. 

配置脚本会运行并且检查你的系统,然后生成必要的文件,以使得编译能够顺利进行,
如果运行失败,你通常会得到一个有用的错误信息,告诉你出错原因.在很多时候,你
会发现由于缺少线程库(threading libraries)而导致配置脚本运行失败.此时,你要
检查一下你的系统,确保你已经安装了MIT-pthreads,如果没有,将其加入系统.对于
Linux用户,则需要下载并且安装LinuxThreads.这些库文件是必须的,他们使MySQL能
够支持多线程(比如,同时运行多个版本的MySQL),最近的Linux发行套件可能已经安
装了这些库文件.

    The configure script will run and inspect your system and then build
    the necessary files to successfully compile. If it fails, you'll 
    usually get a helpful error message saying why. Quite often, you'll 
    find the script will fail when it's looking for threading libraries. 
    Check that you've got MIT-pthreads installed on your machine, and if 
    not, add them. Linux users will have to download LinuxThreads. These 
    are critical libraries that allow MySQL to multithread (i.e., run 
    multiple versions of itself). Recent distributions of Linux may
     already have these libraries installed. 

配置成功之后,简单地输入"make",然后就可以坐在一边喝杯咖啡,等候其编译完成.
MySQL是一个复杂的软件,完成编译需要花些时间.如果编译错误,查看一下相关文档,
看看是不是因为你的操作系统缺少某些东西.

    If everything goes according to plan, simply type make and go get a 
    coffee. MySQL is a complex program and takes some time to compile. 
    If you get an error, check the documentation to see if there is 
    anything specific that you've missed for your particular OS. 

紧接着,输入"make install"命令,所需的文件将会被安装在所有必要的的路径,现在,
MySQL已经安装完毕了,如果你以前从未安装和使用过MySQ,你需要创建一个默认的权
限控制,输入"scripts/mysql_install_db"可以进行这项设置.

    Next, type make install and all the necessary files will be installed 
    in all the necessary spots. Now you're almost ready to roll! If you 
    are a MySQL virgin and you've never installed MySQL before, you need 
    to create the default permissions, so type ... scripts/mysql_install_db 
    to set these up. 

好了,MySQL已经一切就绪了,我们所要做的就是在操作系统启动和关机时,添加启动和
停止MySQL服务器的功能,当然,已经有现成的脚本脚本可以启动和停止MySQL,其命令
格式分别是"mysql.server start"和"mysql.server stop",这两个命令的含义显而易
见.如果想手工启动服务器(这样就不用重新启动操作系统),只要进入MySQL的安装目录
(/usr/local/mysql)并且输入"./bin/safe_mysqld &"即可.

    That's it. We're ready to roll. All we need to do is add the ability to 
    start and stop the server at boot-up and shutdown times. And yes, there's 
    a script for that as well. Typing mysql.server start starts the server, 
    and mysql.server stop stops the server. It's kind of obvious, really. 
    To start the server manually (so you can play without rebooting) enter 
    the root directory in your MySQL installation (/usr/local/mysql) and 
    type bin/safe_mysqld &. 

PHP/MySQL的安装工作目前已经完成一半了,下面继续安装PHP.

    You're halfway there. Now on to PHP. 

[未完待续]

--

                              Enjoy Linux!
                          -----It's FREE!-----

※ 来源:.紫 丁 香 bbs.hit.edu.cn.[FROM: Baggio.hit.edu.c]
[百宝箱] [返回首页] [上级目录] [根目录] [返回顶部] [刷新] [返回]
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:24.089毫秒