📄 install.pod
字号:
it is an installation option of the MySQL setup program(Custom installation), whether the header files are installedor not. On Red Hat Linux, you need to install an RPM archiveF<mysql-devel> or F<MySQL-devel>.If you know the location of the header files, then you willneed to add an option -L<header directory>to the C compiler flags, for example C<-L/usr/include/mysql>.=head2 Linker flagsAppropriate linker flags are the most common source of problemswhile installing DBD::mysql. I will only give a rough overview,you'll find more details in the troubleshooting section.L<KNOWN PROBLEMS>The determination of the C compiler flags is usually left toa configuration script called F<mysql_config>, which can beinvoked with mysql_config --libsWhen doing so, it will emit a line with suggested C compilerflags, for example like this: -L'/usr/lib/mysql' -lmysqlclient -lnsl -lm -lz -lcryptThe following items typically need to be configured for thelinker:=over=item The mysqlclient libraryThe MySQL client library comes as part of the MySQL distribution.Depending on your system it may be a file called F<libmysqlclient.a> statically linked library, Unix F<libmysqlclient.so> dynamically linked library, Unix F<mysqlclient.lib> statically linked library, Windows F<mysqlclient.dll> dynamically linked library, Windowsor something similar.As in the case of the header files, the client library is typicallynot installed by default. On Windows you will need to select themwhile running the MySQL setup program (Custom installation). OnRed Hat Linux an RPM archive F<mysql-devel> or F<MySQL-devel> mustbe installed.The linker needs to know the location and name of the mysqlclientlibrary. This can be done by adding the flags -L<lib directory> -lmysqlclientor by adding the complete path name. Examples: -L/usr/lib/mysql -lmysqlclient -LC:\mysql\lib -lmysqlclientIf you would like to use the static libraries (and there areexcellent reasons to do so), you need to create a separatedirectory, copy the static libraries to that place and usethe -L switch above to point to your new directory. For example: mkdir /tmp/mysql-static cp /usr/lib/mysql/*.a /tmp/mysql-static perl Makefile.PL --libs="-L/tmp/mysql-static -lmysqlclient" make make test make install rm -rf /tmp/mysql-static=item The gzip libraryThe MySQL client can use compression when talking to the MySQLserver, a nice feature when sending or receiving large texts overa slow network.On Unix you typically find the appropriate file name by running ldconfig -p | grep libz ldconfig -p | grep libgzOnce you know the name (libz.a or libgz.a is best), just add itto the list of linker flags. If this seems to be causing problemyou may also try to link without gzip libraries.=back=head1 SPECIAL SYSTEMSBelow you find information on particular systems:=head2 Windows/CygWinIf you are a user of Cygwin (the Redhat distribution) you alreadyknow, it contains a nicely running perl 5.6.1, installation ofadditional modules usually works as a charme via the standardprocedure of perl makefile.PL make make test make installThe Windows binary distribution of MySQL runs smoothly under Cygwin.You can start/stop the server and use all Windows clients without problem.But to install DBD::mysql you have to take a little special action.Don't attempt to build DBD::mysql against either the MySQL Windows orLinux/Unix BINARY distributions: neither will work!You MUST compile the MySQL clients yourself under Cygwin, to get a'libmysqlclient.a' compiled under Cygwin. Really! You'll only needthat library and the header files, you don't need any other client parts.Continue to use the Windows binaries. And don't attempt (currently) tobuild the MySQL Server part, it is unneccessary, as MySQL AB does anexcellent job to deliver optimized binaries for the mainstreamoperating systems, and it is told, that the server compiled under Cygwin isunstable.Install MySQL (if you havn't already)=over=item -download the MySQL Windows Binaries fromhttp://www.mysql.com/downloads/index.html=item -unzip mysql-<version>-win.zip into some temporary location=item -start the setup.exe there and follow the instructions=item -start the server=item -alternatively download, install and start the server on a remoteserver, on what supported OS ever=backBuild MySQL clients under Cygwin:=over=item -download the MySQL LINUX source fromhttp://www.mysql.com/downloads/index.html=item -unpack mysql-<version>.tar.gz into some tmp location=item -cd into the unpacked dir mysql-<version> ./configure --prefix=/usr/local/mysql --without-serverThis prepares the Makefile with the installed Cygwin features. Ittakes some time, but should finish without error. The 'prefix', asgiven, installs the whole Cygwin/MySQL thingy into a location notnormally in your PATH, so that you continue to use already installedWindows binaries. The --without-server parameter tells configure toonly build the clients.=item - makeThis builds all MySQL client parts ... be patient. It should finishfinally without any error.=item - make installThis installs the compiled client files under /usr/local/mysql/.Remember, you don't need anything except the library under/usr/local/mysql/lib and the headers under /usr/local/mysql/include!Essentially you are now done with this part. If you want, you may tryyour compiled binaries shortly; for that, do:=item - cd /usr/local/mysql/bin ./mysql -h 127.0.0.1The host (-h) parameter 127.0.0.1 targets the local host, but forcesthe mysql client to use a TCP/IP connection. The default would be apipe/socket connection (even if you say '-h localhost') and thisdoesn't work between Cygwin and Windows (as far as I know).If you have your MySQL server running on some other box, then pleasesubstitute '127.0.0.1' with the name or IP-number of that box.=backPlease note, in my environment the 'mysql' client did not accept asimple RETURN, I had to use CTRL-RETURN to send commands... strange,but I didn't attempt to fix that, as we are only interested in thebuilt lib and headers.At the 'mysql>' prompt do a quick check: mysql> use mysql mysql> show tables; mysql> select * from db; mysql> exitYou are now ready to build DBD::mysql!Build DBD::mysql:=over=item -download DBD-mysql-<version>.tar.gz from CPAN=item -unpack DBD-mysql-<version>.tar.gz=item -cd into unpacked dir DBD-mysql-<version>you probably did that already, if you are reading this!=item - cp /usr/local/mysql/bin/mysql_config .This copies the executable script mentioned in the DBD::mysql docsfrom your just built Cywin/MySQL client directory; it knows aboutyour Cygwin installation, especially about the right libraries to linkwith.=item - perl Makefile.PL --testhost=127.0.0.1The --testhost=127.0.0.1 parameter again forces a TCP/IP connectionto the MySQL server on the local host instead of a pipe/socketconnection for the 'make test' phase.=item - makeThis should run without error=item - make testwith DBD-mysql-2.1022 or earlier you will see several errors indbdadmin.t, mysql.t and mysql2.t; with later versions you should notget errors (except possibly one, indicating, that some tables couldnot be dropped. I'm hunting for a solution to that problem, but havenone yet).=item - make installThis installs DBD::mysql into the Perl hierarchy.=backNotes:This was tested with MySQL version 3.23.54a and DBD::mysql version2.1022. I patched the above mentioned test scripts and sent thepatchesto the author of DBD::mysql Jochen Wiedman.Georg Rehfeld 15. Jan. 2003=head1 KNOWN PROBLEMS=over=item 1.)Some Linux distributions don't come with a gzip library by default.Running "make" terminates with an error message like LD_RUN_PATH="/usr/lib/mysql:/lib:/usr/lib" gcc -o blib/arch/auto/DBD/mysql/mysql.so -shared -L/usr/local/lib dbdimp.o mysql.o -L/usr/lib/mysql -lmysqlclient -lm -L/usr/lib/gcc-lib/i386-redhat-linux/2.96 -lgcc -lz /usr/bin/ld: cannot find -lz collect2: ld returned 1 exit status make: *** [blib/arch/auto/DBD/mysql/mysql.so] Error 1If this is the case for you, install an RPM archive likelibz-devel, libgz-devel, zlib-devel or gzlib-devel or somethingsimilar.=item 2.)If Perl was compiled with gcc or egcs, but MySQL was compiledwith another compiler or on another system, an error message likethis is very likely when running "Make test": t/00base............install_driver(mysql) failed: Can't load '../blib/arch/auto/DBD/mysql/mysql.so' for module DBD::mysql: ../blib/arch/auto/DBD/mysql/mysql.so: undefined symbol: _umoddi3 at /usr/local/perl-5.005/lib/5.005/i586-linux-thread/DynaLoader.pm line 168.This means, that your linker doesn't include libgcc.a. You havethe following options:The solution is telling the linker to use libgcc. Run gcc --print-libgcc-fileto determine the exact location of libgcc.a or for older versionsof gcc gcc -vto determine the directory. If you know the directory, add a -L<directory> -lgccto the list of C compiler flags. L</Configuration>. L</Linker flags>.=item 3.)There are known problems with shared versions of libmysqlclient,at least on some Linux boxes. If you receive an error messagesimilar to install_driver(mysql) failed: Can't load '/usr/lib/perl5/site_perl/i586-linux/auto/DBD/mysql/mysql.so' for module DBD::mysql: File not found at /usr/lib/perl5/i586-linux/5.00404/DynaLoader.pm line 166then this error message can be misleading: It's not mysql.sothat fails being loaded, but libmysqlclient.so! The usualproblem is that this file is located in a directory like /usr/lib/mysqlwhere the linker doesn't look for it.The best workaround is using a statically linked mysqlclientlibrary, for example /usr/lib/mysql/libmysqlclient.aThe use of a statically linked library is described in theprevious section on linker flags. L</Configuration>.L</Linker flags>. =item 4.)Red Hat 8 & 9 set the Default locale to UTF which causes problems with MakeMaker. To build DBD::mysql on these systems, do a 'unset LANG' before runing 'perl Makefile.PL'=back=head1 SUPPORTFinally, if everything else fails, you are not alone. First ofall, for an immediate answer, you should look into the archivesof the mailing list B<perl@lists.mysql.com>. Seehttp://www.mysql.com for archive locations.If you don't find an appropriate posting and reply in themailing list, please post a question. Typically a reply willbe seen within one or two days.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -