📄 manual_installing.html
字号:
<li>属于特定系统的选项可在本章特定系统的小节里找到。见<a HREF="manual_Installing.html#Source_install_system_issues">4.11 系统特定的问题</a>。</li>
</ul>
<h2><a NAME="Compilation_problems" HREF="manual_toc.html#Compilation_problems">4.8
编译问题?</a></h2>
<p>所有<strong>MySQL</strong>程序在Solaris上使用<code>gcc</code>编译并且没有任何警告。在其他系统上,由于系统包含文件的差别可能会发生警告。对于使用MIT-pthreads时发生的警告,见<a HREF="manual_Installing.html#MIT-pthreads">4.9 MIT-pthreads 注意事项</a>。其他问题,检查下面的表。
</p>
<p>许多问题的解决方案涉及重新配置。如果你确实需要重新配置,注意下列事项:
<a NAME="IDX52"></a> <a NAME="IDX53"></a>
<ul>
<li>如果<code>configure</code>在它已经被运行了以后运行,它可以使用先前收集的信息。这个信息被存储在<tt>“config.cache”</tt>里面。当<code>configure</code>启动时,它寻找该文件而且如果它存在,假定信息仍然是正确的,读入它的内容。当你重新配置时,该假设是无效的。
</li>
<li>每次你运行<code>configure</code>时候,你必须运行<code>make</code>再重新编译。然而,
你可能想要把先前构造的老的目标文件删除,因为他们使用不同的配置选项被编译。
</li>
</ul>
<p>为了防止使用旧的配置信息或目标文件,在重新运行<code>configure</code>前运行这些命令:
</p>
<pre>
shell>rm config.cache
shell>make clean
</pre>
<p>另外,你可以运行<code>make distclean</code>。 </p>
<p>下表描述了一些最常发生的编译<strong>MySQL</strong>的问题:
<ul>
<li><a NAME="IDX58"></a>如果在编译<tt>“sql_yacc.cc”</tt>时,你得到如下的一个错误,你可能是存储器或交换空间溢出:
<pre>Internal compiler error: program cc1plus got fatal signal 11
或
Out of virtual memory
或
Virtual memory exhausted
</pre>
<p>该问题是<code>gcc</code>要求大量的内存编译<tt>带有嵌入函数(inline
function)的“sql_yacc.cc”</tt>。试试以<code>--with-low-memory</code>选项运行<code>configure</code>:
</p>
<pre>
shell>./configure -- with-low-memory</pre>
<p>如果你正在使用<code>gcc</code>,该选项使得<code>将-fno-inline</code>加到编译行,如果你正在使用其他的编译器,则加入<code>-O0</code>。你应该试一试<code>--with-low-memory</code>选项,即使你有特别多的存储器和交换空间,而你认为不能可能运行得溢出。这个问题甚至在很慷慨的硬件配置的系统上出现,通常用<code>--with-low-memory</code>选项修正它。
</p>
</li>
<li>缺省地,<code>configure</code>挑选<code>c++</code>作为编译器名字并用<code>-lg++</code>选项的GNU<code>
c++</code>链接。如果你正在使用<code>gcc</code>,这个特性在配置期间导致如下问题:
<a NAME="IDX59"></a> <pre>configure: error: installation or configuration problem:
C++ compiler cannot create executables.
</pre>
<p><a NAME="IDX60"></a><a NAME="IDX61"></a>你可能也在编译期间看到<code>g++</code>、<code>libg++</code>或<code>libstdc++</code>相关的问题。这些问题的一个原因是你可能没有<code>g++</code>,或你可能有<code>g++</code>但无<code>libg++</code>或<code>libstdc++</code>。看一下<tt>“config.log”</tt>文件。它应该包含你的c++编译器不能工作的准确原因!为了解决这些问题,你可以使用<code>gcc</code>作为你的C++编译器。试试设置环境变量<code>CXX</code>为<code>"gcc
-O3"</code>。例如: <a NAME="IDX62"></a> <a NAME="IDX63"></a> </p>
<pre>
shell>CXX="gcc -O3" ./configure</pre>
<p>它能工作,因为<code>gcc</code>象<code>g++</code>一样编译C++源代码,但缺省地它不链接<code>libg++</code>或<code>libstdc++</code>。解决这些问题的其他方法当然是安装<code>g++</code>、<code>libg++</code>和<code>libstdc++</code>。
</p>
</li>
<li>如果你的编译以下面任何错误而失败,你必须升级<code>make</code>版本到GNU<code>make</code>:
<pre>making all in mit-pthreads
make: Fatal error in reader: Makefile, line 18:
Badly formed macro assignment
or
make: file `Makefile' line 18: Must be a separator (:
or
pthread.h: No such file or directory
</pre>
<p><a NAME="IDX64"></a><a NAME="IDX67"></a>Solaris和FreeBSD已知<code>make</code>程序有问题。GNU
<code>make</code>版本3.75已知能工作。 <a NAME="IDX68"></a> <a NAME="IDX69"></a> <a NAME="IDX70"></a> <a NAME="IDX71"></a> <a NAME="IDX72"></a> <a NAME="IDX73"></a> <a NAME="IDX74"></a> <a NAME="IDX75"></a> </p>
</li>
<li>如果你想要定义你的C或C++编译器所使用的标志,把标志加到<code>CFLAGS</code>和<code>CXXFLAGS</code>环境变量中即可。你也能使用<code>CC</code>和<code>CXX</code>来指定编译器名字。例如:
<pre>
shell>CC=gcc
shell>CFLAGS=-O6
shell>CXX=gcc
shell>CXXFLAGS=-O6
shell>export CC CFLAGS CXX CXXFLAGS
</pre>
<p>对于已经知道在不同系统上有用的标志定义列表,见<a HREF="manual_Installing.html#TcX_binaries">4.14 TcX 二进制代码</a>。 </p>
</li>
<li>如果你得到象如下的一条错误消息,你需要升级你的<code>gcc</code>编译器:
<pre>
client/libmysql.c:273: parse error brfore '__attribute__'</pre>
<p><code>gcc</code>2.8.1已知可以工作,但是我们推荐使用<code>egcs</code>1.0.3a或更新。
</p>
</li>
<li>如果你在编译<code>mysqld</code>时显示例如下面的那些错误, <code>configure</code>没有正确地检测传到<code>accept()</code>、<code>getsockname()</code>或<code>getpeername()</code>最后参数的类型:
<pre>cxx: Error: mysqld.cc, line 645: In this statement, the referenced
type of the pointer value "&length" is "unsigned long", which
is not compatible with "int".
new_sock = accept(sock, (struct sockaddr *)&cAddr, &length);
</pre>
<p>为了修正它,编辑<tt>“config.h”</tt>文件(它由<code>configure</code>生成)。寻找这些行:
</p>
<pre>/* Define as the base type of the last arg to accept */
#define SOCKET_SIZE_TYPE XXX
</pre>
<p>更改<code>XXX</code>为<code>size_t</code>或<code>int</code>,这取决于你的操作系统。(注意:你每次运行<code>configure</code>都必须这样做,因为<code>configure</code>重新生成<tt>“config.h”</tt>。)</p>
</li>
<li><tt>“sql_yacc.cc”</tt>文件由<tt>“sql_yacc.yy”</tt>生成。通常构造过程不需要创造<tt>“sql_yacc.cc”</tt>,因为<strong>MySQL</strong>有一个已经生成的拷贝,然而,如果你确实需要再创建它,你可能碰到这个错误:
<pre>"sql_yacc.yy", line xxx fatal: default action causes potential...
</pre>
<p>这是一个你的<code>yacc</code>版本不完善的迹象。你可能需要安装<code>bison</code>(GNU
版本<code>yacc</code>)并使用它。 </p>
</li>
<li>如果你需要调试<code>mysqld</code>或<strong>MySQL</strong>客户,运行<code>configure</code>,使用<code>--with-debug</code>选项,然后重新编译并且链接你客户程序到新的客户库。见<a HREF="manual_Porting.html#Debugging_client">G.2 调试一个MySQL客户</a>。 </li>
</ul>
<h2><a NAME="MIT-pthreads" HREF="manual_toc.html#MIT-pthreads">4.9 MIT-pthreads注意事项</a></h2>
<p>这节描述在使用 MIT-pthreads 所涉及的一些问题。 </p>
<p>注意:在Linux上,你应该不使用MIT-pthreads而是安装LinuxThreads!见<a HREF="manual_Installing.html#Linux">4.11.5 Linux 注意事项(所有的Linux 版本)</a>。
</p>
<p>如果你的系统不提供原生的线程支持,你将需要使用MIT-pthreads包构造<strong>MySQL</strong>。这包括大多数FreeBSD系统、SunOS
4.x 、Solaris 2.4和更早版本及其他,见<a HREF="manual_Installing.html#Which_OS">4.2
MySQL 支持的操作系统</a>。
<ul>
<li>在大多数系统上,你能通过使用<code>configure</code>,用<code>--with-mit-threads</code>选项来强迫运行MIT-pthreads:
<pre>
shell> ./configure -- with-mit-threads</pre>
<p>当使用MIT-pthreads时,不支持在一个非源代码目录构造,因为我们想要使我们对代码的改变减到最小。
</p>
</li>
<li>MIT-pthreads不支持用于实现Unix套接字<code>的AF_UNIX</code>协议。这意味着如果你使用MIT-pthreads进行编译,所有的链接必须使用TCP/IP进行(它有点慢)。如果在构造<strong>MySQL</strong>后,你发现你不能与本地的服务器连接,很可能是客户程序正在试图用缺省的Unix套接字与<code>localhost</code>连接。使用主机选择(<code>-h</code>或<code>--host</code>)明确地指定本地的主机名字,尝试做一个TCP/IP连接<code>到mysql</code>。
</li>
<li>决定是否使用MIT-pthreads的检查仅在处理服务器代码的配置过程期间发生。如果已经用<code>--without-server</code>配置了分发并只构造客户代码,客户将不知道MIT-pthreads是否正在被使用并且是否使用缺省的Unix套接字连接。因为Unix套接字不能在MIT-pthreads下面工作,这意味着当你运行客户程序时,你将需要使用<code>-h</code>或<code>--host</code>。
</li>
<li>当使用MIT-pthreads编译<strong>MySQL</strong>时,因为性能原因,系统锁定缺省为禁止使用。你可以用<code>--use-locking</code>选项告诉服务器使用系统锁定。
</li>
<li>有时pthread<code>bind()</code>命令不能绑定一个套接字但没有任何错误消息(至少在Solaris上),结果是所有到服务器的连接均失败。例如:
<pre>shell> mysqladmin version
mysqladmin: connect to server at '' failed;
error: 'Can't connect to mysql server on localhost (146)'
</pre>
<p>解决它的方法是杀死<code>mysqld</code>服务器并且重启它。这只有当我们强迫服务器停止并马上进行重启时在发生。
</p>
</li>
<li>使用MIT-pthreads,<code>sleep()</code>系统调用不是可中断的<code>SIGINT</code>(break)。这只有在你运行<code>mysqladmin
--sleep</code>时才能注意到。你在中断起作用并且进程停止之前必须等待<code>sleep()</code>终止。
</li>
<li>当链接时,你可能会收到这样的警告消息(至少在Solaris上);他们可以被忽视:
<pre>ld: warning: symbol `_iob' has differing sizes:
(file /my/local/pthreads/lib/libpthread.a(findfp.o) value=0x4;
file /usr/lib/libc.so value=0x140);
/my/local/pthreads/lib/libpthread.a(findfp.o) definition taken
ld: warning: symbol `__iob' has differing sizes:
(file /my/local/pthreads/lib/libpthread.a(findfp.o) value=0x4;
file /usr/lib/libc.so value=0x140);
/my/local/pthreads/lib/libpthread.a(findfp.o) definition taken
</pre>
</li>
<li>一些其他的警告也可被忽略: <pre>implicit declaration of function `int strtoll(...)'
implicit declaration of function `int strtoul(...)'
</pre>
</li>
<li>我们还没有让<code>readline</code>可在MIT-pthreads上工作。(这不需要,但是可能某些人有兴趣。)</li>
</ul>
<h2><a NAME="Perl_support" HREF="manual_toc.html#Perl_support">4.10 Perl 安装说明</a></h2>
<h3><a NAME="Perl_installation" HREF="manual_toc.html#Perl_installation">4.10.1 在Unix上安装Perl</a></h3>
<p>Perl对<strong>MySQL</strong>的支持借助<code>DBI</code>/<code>DBD</code>客户接口而提供。见<a HREF="manual_Clients.html#Perl">20.5 MySQL Perl API</a>。Perl<code> DBD</code>/<code>DBI</code>客户代码要求Perl
5.004或以后版本。如果你有Perl的一个更旧的版本,接口<em>将不能工作</em>。
</p>
<p><strong>MySQL</strong> Perl支持也要求你安装了<strong>MySQL</strong>客户编程支持。如果你从RPM文件安装<strong>MySQL</strong>,客户程序在客户RPM中,但是客户编程支持在开发者RPM。确定你安装了后一个RPM
。 </p>
<p>对于版本3.22.8,Perl支持是与主要<strong>MySQL</strong>发行版本单独分发。如果你想要安装Perl支持,你需要的文件能从<a HREF="http://www.mysql.com/Contrib">http://www.mysql.com/Contrib</a>获得。 </p>
<p>Perl 分发以压缩的<code>tar</code>档案提供,并且有一个类似<tt>“MODULE-VERSION.tar.gz”</tt>的名字,这里<code>MODULE</code>是模块名字并且<code>VERSION</code>是版本号。你应该得到<code>Data-Dumper</code>、DBI和<code>Msql-Mysql-modules</code>分发并按此次序安装他们。安装过程显示出在下面,显示的例子针对<code>Data-Dumper</code>模块,
但是所有3个过程是相同的。
<ol>
<li>解包分发到当前目录: <pre>
shell> gunzip < Data-Dumper-VERSION.tar.gz | tar xvf -</pre>
<p>这个命令创建的一个名为<tt>“Data-Dumper-VERSION”</tt>的目录。 </p>
</li>
<li>进入解包分发的顶级目录: <pre>shell> cd Data-Dumper-VERSION</pre>
</li>
<li>构造分发并且编译所有东西: <pre>shell> perl Makefile.PL
shell> make
shell> make test
shell> make install
</pre>
</li>
</ol>
<p><code>make test</code>命令很重要,因为它验证模块正在工作。注意:在你<code>Msql-Mysql-modules</code>安装期间运行该命令试验接
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -