8.4 中文镜像

MySQL 8.4 参考手册 · 中文镜像

正文为中文,英文原文默认隐藏。点击任意中文段落即可展开 / 收起对应英文原文。

打开官方英文原文 ↗

译文由机器翻译生成,仅供理解参考;有疑问请以官方英文原文为准。

中文点击中文段落可显示 / 隐藏英文原文本页译文覆盖 100%

2.10.1 在 Unix 上安装 Perl2.10.1 Installing Perl on Unix

MySQL Perl 支持要求您安装 MySQL 客户端编程支持(库和头文件)。大多数安装方法都会安装必要的文件。如果您在 Linux 上从 RPM 文件安装 MySQL,请务必同时安装开发人员 RPM。客户端程序位于客户端 RPM 中,但客户端编程支持位于开发人员 RPM 中。MySQL Perl support requires that you have installed MySQL client programming support (libraries and header files). Most installation methods install the necessary files. If you install MySQL from RPM files on Linux, be sure to install the developer RPM as well. The client programs are in the client RPM, but client programming support is in the developer RPM.

Perl 支持所需的文件可以从 CPAN(综合 Perl 存档网络)获取,网址为 http://search.cpan.org。The files you need for Perl support can be obtained from the CPAN (Comprehensive Perl Archive Network) at http://search.cpan.org.

在 Unix 上安装 Perl 模块的最简单方法是使用 CPAN 模块。例如:The easiest way to install Perl modules on Unix is to use the CPAN module. For example:

$> perl -MCPAN -e shell
cpan> install DBI
cpan> install DBD::mysql

DBD::mysql 安装运行了许多测试。这些测试尝试使用默认用户名和密码连接到本地 MySQL 服务器。 (在 Unix 上,默认用户名是您的登录名;在 Windows 上,ODBC。默认密码是 “无密码。”)如果您无法使用这些值连接到服务器(例如,如果您的帐户有密码),则测试将失败。您可以使用force install DBD::mysql来忽略失败的测试。The DBD::mysql installation runs a number of tests. These tests attempt to connect to the local MySQL server using the default user name and password. (The default user name is your login name on Unix, and ODBC on Windows. The default password is “no password.”) If you cannot connect to the server with those values (for example, if your account has a password), the tests fail. You can use force install DBD::mysql to ignore the failed tests.

DBI需要Data::Dumper模块。可以安装;如果没有,您应该在安装 DBI 之前安装它。DBI requires the Data::Dumper module. It may be installed; if not, you should install it before installing DBI.

也可以以压缩 tar 存档的形式下载模块发行版并手动构建模块。例如,要解压并构建 DBI 发行版,请使用如下过程:It is also possible to download the module distributions in the form of compressed tar archives and build the modules manually. For example, to unpack and build a DBI distribution, use a procedure such as this:

  1. 将发行版解压到当前目录:Unpack the distribution into the current directory:

    $> gunzip < DBI-VERSION.tar.gz | tar xvf -
    

    此命令创建一个名为 DBI-VERSION 的目录。This command creates a directory named DBI-VERSION.

  2. 将位置更改为解压发行版的顶级目录:Change location into the top-level directory of the unpacked distribution:

    $> cd DBI-VERSION
    
  3. 构建发行版并编译所有内容:Build the distribution and compile everything:

    $> perl Makefile.PL
    $> make
    $> make test
    $> make install
    

该make test命令很重要,因为它验证模块是否正常工作。请注意,当你在安装过程中执行该命令DBD::mysql以练习接口代码时,MySQL 服务器必须在运行,否则测试将失败。The make test command is important because it verifies that the module is working. Note that when you run that command during the DBD::mysql installation to exercise the interface code, the MySQL server must be running or the test fails.

每当您安装新版本的 MySQL 时,最好重建并重新安装 DBD::mysql 发行版。这可确保正确安装最新版本的 MySQL 客户端库。It is a good idea to rebuild and reinstall the DBD::mysql distribution whenever you install a new release of MySQL. This ensures that the latest versions of the MySQL client libraries are installed correctly.

如果您没有在系统目录中安装 Perl 模块的访问权限,或者想要安装本地 Perl 模块,以下参考可能会很有用:http://learn.perl.org/faq/perlfaq8.html#How-do-I-keep-my-own-module-library-directory-If you do not have access rights to install Perl modules in the system directory or if you want to install local Perl modules, the following reference may be useful: http://learn.perl.org/faq/perlfaq8.html#How-do-I-keep-my-own-module-library-directory-