ºìÁªLinuxÃÅ»§
Linux°ïÖú

ÈÃMySQLÓëOpenOffice¹²Îè

·¢²¼Ê±¼ä:2006-01-07 09:35:09À´Ô´:ºìÁª×÷Õß:Myiozzdoc
Ò»ÄêÇ°£¬ÎÒ³ÉΪÁËLinuxÓû§µÄÒ»Ô±£¬µ«ÊǶàÄêʹÓÃWindows£¬ÈÃÎÒ¾õµÃLinuxÓеŤ¾ßʹÓò»ºÜÏ°¹ß¡£¾ÍÄÃÊý¾Ý¿âÀ´Ëµ£¬ÔÚWindowsÏ£¬¿ª·¢Ò»Ð©Êý¾Ý¿âÇý¶¯µÄÍøÕ¾»òÕßСÐ͹ÜÀíϵͳʱ¿ÉÒÔÑ¡ÔñʹÓÃAccess¡£Access²»½öÒ×ÓÚʹÓ㬶øÇҷdz£·½±ã¡£×ªµ½LinuxÉϺó£¬×öͬÑùÊÂÇéʱ·¢ÏÖMySQLÊÇÒ»¸ö²»´íµÄÑ¡Ôñ£¬µ«ÆäûÓÐͼÐνçÃ棬ʹÓÃÆðÀ´²»ÊǺܷ½±ã£¬ÓÚÊÇÏ£ÍûÄܹ»ÕÒµ½½â¾öµÄ·½°¸¡£¾­¹ýÒ»¶Îʱ¼äµÄ̽Ѱ£¬ÖÕÓÚÕÒµ½Á˽â¾ö°ì·¨£¬¼´°ÑMySQLºÍOpenOffice½áºÏʹÓ᣸ù¾Ý×ÊÁÏÏÔʾ£¬ÊµÏÖMySQLºÍOpenOfficeЭͬ¹¤×÷µÄ·½·¨ÓкܶàÖÖ£¬²»¹ý´ó¶¼¹ýÓÚ¸´ÔÓ£¬ÄÑÓÚʵÏÖ¡£ÔÚ´ËÎÒ½éÉÜÁ½ÖÖ°²×°ºÍÅäÖùý³Ì¡£

¡¡¡¡ÎÒʹÓõIJÙ×÷ϵͳÊÇRed Hat 8.0£¬Í¬ÑùµÄ·½·¨ÓÃÓÚÆäËüµÄ·¢Ðаæ¿ÉÄÜÉÔÓв»Í¬¡£ÔÚ°²×°ÅäÖùý³ÌÖУ¬ÐèÒªMySQLºÍunixODBCÈí¼þ°ü(OpenOfficeȱʡÇé¿öÏÂÒѾ­°²×°ºÃÁË)¡£ÕâЩÈí¼þ°üÔÚRed Hat 8.0µÄ¹âÅÌÖж¼ÒѾ­×Ô´ø£¬µ«ÔÚÎҵIJâÊÔÖУ¬Ê¹Óð²×°Å̵ķ½·¨ËƺõÎÞ·¨³É¹¦¡£

¡¡¡¡°²×°ÅäÖ÷½·¨Ò»



¡¡¡¡1.ÏÂÔØÈí¼þ

¡¡¡¡ËùÐèÒªµÄÈí¼þ°üÓУº

mysql-3.23.55-pc-linux-i686.tar
MySQL-client-3.23.55-1.i386
MySQL-shared-3.23.55-1.i386
MyODBC-2.50.39-1.i386
unixODBC-2.2.4.tar



¡¡¡¡ÕâЩÈí¼þ°ü¿É·Ö±ð¿É´ÓÒÔÏÂÕ¾µãÏÂÔØ£º

http://mirrors.sunsite.dk/mysql/Downloads/MySQL-3.23/
http://mysql.azc.uam.mx/Downloads/MyODBC/
http://www.unixodbc.org



¡¡¡¡ÉÏÃæËùÁеÄÊÇÎҸоõËٶȱȽϿìµÄÕ¾µã£¬ÊÂʵÉÏÔںܶྵÏñÕ¾µã¶¼¿ÉÒÔÏÂÔص½ÕâЩÈí¼þ°ü¡£

¡¡¡¡2.°²×°Èí¼þ

¡¡¡¡Ê¹ÓÃÒÔÏÂÃüÁî(ÒÔrootÉí·Ý)À´²é¿´ÒÔÇ°ÊÇ·ñ°²×°¹ý£º

rpm -qa | grep -i mysql
rpm -e (·¢ÏÖµÄËùÓÐÈí¼þ°ü)
updatedb
rpm -qa | grep -i odbc
rpm -e (ËùÓз¢ÏÖµÄÈí¼þ°ü)



¡¡¡¡Çл»ÖÁÏÂÔصÄÈí¼þ°üËùÔÚµÄĿ¼£¬ÒÔrootÓû§µÄÉí·ÝÖ´ÐÐÒÔÏÂÃüÁ

$cd /usr/local
$tar xzf mysql-3.23.55-pc-linux-i686.tar.gz
$ln -s mysql.3.23.55-pc mysql
$cd mysql
$scripts/mysql_install_db
$chown -R root .
$chown -R mysql data
$chgrp -R mysql .
$bin/safe_mysqld --user=mysql &



¡¡¡¡ÏÂÃæÔËÐÐÒ»¸öMySQL»á»°£º

$./mysql -utest
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1 to server version: 3.23.55
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.



¡¡¡¡Õâ˵Ã÷MySQLÒѾ­³É¹¦°²×°£¬ÏÖÔÚÊäÈ룺

mysql> select version();
+-----------+
| version() |
+-----------+
| 3.23.55 |
+-----------+
1 row in set (0.01 sec)



¡¡¡¡Ê¹ÓÃÃüÁî¡°\s¡±À´²é¿´Ò»Ð©»ù±¾ÐÅÏ¢£º

mysql> \s
--------------
./mysql Ver 11.18 Distrib 3.23.55, for pc-linux (i686)

Connection id: 4
Current database:
Current user: test@localhost
Current pager: stdout
Using outfile: ''
Server version: 3.23.55
Protocol version: 10
Connection: Localhost via UNIX socket
Client characterset: latin1
Server characterset: latin1
UNIX socket: /tmp/mysql.sock
Uptime: 6 min 57 sec
Threads: 1 Questions: 6 Slow queries: 0 Opens: 6 Flush tables:
¡¡¡¡¡¡¡¡1 Open tables: 0 Queries per second avg: 0.014



¡¡¡¡ÎªÁËʵÏÖÎÒÃǵÄÄ¿µÄ£¬ÐèÒª°²×°ÁíÍâÈý¸öÈí¼þ°ü¡£ºÍMySQL²»Í¬µÄÊÇ£¬ÕâÈý¸öÈí¼þ¶¼ÊÇÒÔRPMµÄ¸ñʽ¸ø³öµÄ¡£Çл»ÖÁÈí¼þ°üËùÔÚµÄĿ¼£¬ÔËÐÐÒÔÏÂÃüÁ

[root@myserver odbc]#su
[root@myserver odbc]# rpm -Uvh MySQL-client-3.23.55-1.i386.rpm
Preparing... ########################################### [100%]
1:MySQL-client ########################################### [100%]
[root@myserver odbc]# rpm -Uvh MySQL-shared-3.23.55-1.i386.rpm
Preparing... ########################################### [100%]
1:MySQL-shared ########################################### [100%]
[root@myserver odbc]# rpm -Uvh MyODBC-2.50.39-1.i386.rpm
Preparing... ########################################### [100%]
1:MyODBC ########################################### [100%]



¡¡¡¡ÕâЩÈí¼þ°üµÄ°²×°Ò»°ã¶¼²»»áÓÐʲôÎÊÌâ¡£ÏÂÃæÀ´°²×°unixODBC¡£ÔÚÎÒд±¾ÎÄʱ×îеÄunixODBCÊÇ2.2.5°æ£¬ÌṩÏÂÔصÄÎļþÊÇunixODBC-2.2.5.tar.gz¡£Çл»ÖÁÈí¼þ°üËùÔÚĿ¼£¬ÔËÐÐÒÔÏÂÃüÁ



tar xzf unixODBC-2.2.5.tar.gz



¡¡¡¡Çл»ÖÁunixODBC-2.2.5Ŀ¼£¬ÔËÐÐÏÂÊöÃüÁ

su
./configure
make
make install



¡¡¡¡µ«ÊÇ£¬Õâ¸ö°²×°¹ý³Ì²¢²»Ë³Àû£¬³öÏÖÁËһЩÎÊÌâ¡£Ê×ÏÈÊÇһЩ¿âÎļþµÄλÖÃÎÊÌ⣬ÕâÁ½¸ö¿âÎļþÊÇlibodbcmyS.soºÍlibmyodbc.so£¬ËüÃÇÒ»°ãλÓÚ/usr/local/libĿ¼֮Ï¡£¶øÔÚ°²×°¹ý³ÌÖУ¬odbcinst.iniÅäÖÃÎļþÖÐָʾÕâÁ½¸öÎļþµÄλÖÃÈ´ÔÚusr/libĿ¼֮Ï¡£ËùÒÔÐèÒª¶Ô/etc/odbcinst.iniÎļþ½øÐÐһЩ±à¼­¡£±à¼­Íê³Éºó£¬ÎÒµÄodbcinst.iniÎļþÄÚÈÝÈçÏÂËùʾ£º



[MySQL]
Description = ODBC Driver for MySQL
Driver = /usr/local/lib/libmyodbc.so
Setup = /usr/local/lib/libodbcmyS.so
FileUsate = 1
CPTimeout =
CPReuse =



¡¡¡¡È»ºóÔÙ´´½¨Ò»¸ö/etc/odbc.iniÎļþ£¬ÄÚÈÝÈçÏÂËùʾ£º

Description = MySQL database test
Driver = MySQL
Server = localhost
Database = test
Port = 3306
Socket =
Option =
Stmt =



[MySQL-test]

¡¡¡¡µ«ÊÇ£¬µ±ÎÒ°´ÕÕÊÖ²áÍê³ÉÕâ¸öÎļþʱ£¬·¢ÏÖÔ­À´unixODBCÒѾ­½¨ºÃÁËÕâ¸öÎļþ£¬²»¹ýËü²»ÔÚ/etcĿ¼֮Ï£¬¶øÊÇÔÚ/usr/local/etcĿ¼Ï¡£ÓÚÊÇÎÒ°ÑÉÏÊöÁ½¸ö±à¼­ºÃµÄÎļþ¿½±´ÖÁ¸ÃĿ¼ÖС£

¡¡¡¡´ËÍ⣬°²×°¿âunixODBCʱ»¹ÐèÒªKDEÈí¼þ¿ª·¢¹¤¾ß°ü(ÆäÖÐÒѾ­°üº¬ÁËQt)ºÍXÈí¼þ¿ª·¢¹¤¾ß°ü£¬·ñÔò°²×°¹ý³Ì½«ÎÞ·¨½øÐÐÏÂÈ¥¡£Èç¹ûûÓа²×°¸ÃÈí¼þ°ü£¬ÄÇô¿ÉÒÔÑ¡Ôñ£º¿ªÊ¼Ñ¡µ¥¡úϵͳ¹¤¾ß¡úÈí¼þ°ü¡£Õâʱ¾Í»áÆô¶¯Red HatÈí¼þ°ü¹ÜÀí¹¤¾ß£¬Ñ¡ÖÐÉÏÊöÁ½ÏîÄÚÈÝ(Èçͼ1Ëùʾ)£¬µã»÷È·¶¨½øÐа²×°¡£



¡¡¡¡3.½øÐвâÊÔ

¡¡¡¡Ê×ÏÈ¿´Ò»¿´ODBCºÍMySQLÊÇ·ñ¿ÉÒÔÕýÈ·¹µÍ¨¡£ÎÒʹÓÃisql MySQL-test -vÃüÁîÀ´½øÐвâÊÔ£¬½á¹û³öÏÖÁË¡°Could not SQLConnect¡±µÄ´íÎóÐÅÏ¢¡£ÒòΪÎÒʹÓÃÁËÏÔʾÏêϸÐÅÏ¢µÄ-vÑ¡ÏÒò´ËϵͳÌáʾÎÞ·¨ÕÒµ½/var/lib/mysql/mysql.sockµÄÐÅÏ¢¡£ºóÀ´ÎÒ·¢ÏÖMySQLÊÇ°Ñmysql.sockÎļþ´æ´¢ÔÚÁË/tmpĿ¼Ï£¬¶øODBCÔòÊÇÔÚ/var/lib/mysqlĿ¼Ï²éÕÒ¸ÃÎļþ£¬ÄѹÖËüÃDz»ÄÜ˳Àû¹µÍ¨¡£

¡¡¡¡ÏÖÔÚÒÔrootÉí·ÝÀ´´´½¨Ò»¸ö/var/lib/mysqlĿ¼£¬ËæºóÔËÐÐÒÔÏÂÃüÁ

chown -R mysql.mysql /var/lib/mysql



¡¡¡¡È»ºóÖØÐÂÆô¶¯mysqld£¬²¢ÇÒÖ¸Ã÷ÁËÓû§ÃûºÍsocketµÄλÖã¬ÃüÁîÈçÏÂËùʾ£º

bin/safe_mysqld --user=mysql --socket=/var/lib/mysql/mysql.sock &



¡¡¡¡ÔÙ²âÊÔÒ»±é£¬½á¹ûÒ»ÇÐÕý³£¡£ÏÖÔÚ¿ÉÒÔ½øÐÐÒÔϲâÊÔÁË£º

/ isql MySQL-test -v
+---------------------------------------+
| Connected! |
| |
| sql-statement |
| help [tablename] |
| quit |
| |
+---------------------------------------+
SQL> select version();
+----------+
| version()|
+----------+
| 3.23.55 |
+----------+
1 rows affected
1 rows returned



¡¡¡¡¾­¹ýÇ°Ãæ²»¶ÏµØʧ°Ü£¬ÎÒ¶¼²»¸ÏÏàÐÅÈí¼þÓû§ÊÖ²áÁË¡£½Ó×Å£¬Æô¶¯OpenOffice Writer£¬È»ºóÑ¡Ôñ¹¤¾ß¡úÊý¾ÝÔ´¡£Õâʱ£¬ÓÖÒ»¸ö´íÎó³öÏÖ£¬OpenOfficeÏÔʾ˵ÎÞ·¨ÕÒµ½libodbc.so¡£ÎÒ°Ñlibodbc.so´Ó/usr/local/lib¿½±´µ½/usr/libºó£¬ÎÊÌâ¾Í½â¾öÁË¡£ÓÚÊÇ£¬Ò»Çж¼Õý³£ÁË¡£Í¼2ÊÇOpenOfficeµÄ±íÉè¼Æ´°¿Ú£¬ÔÚÕâ¸ö´°¿ÚÖУ¬ÎÒºÜÈÝÒ×¾ÍÍê³ÉÁËÒ»¸ö±íµÄÉè¼Æ£¬ÕæÊÇÌ«°ôÁË¡£



¡¡¡¡ËäÈ»ÒѾ­³É¹¦£¬µ«ÊÇÎÒ»¹ÊDz»¾õµÃÇáËÉ£¬±Ï¾¹Õâ¸ö·½·¨¹ýÓÚ¸´ÔÓ¡£ÓÚÊÇ£¬ÎÒ¿ªÊ¼Ñ°Çó¸ü¼òµ¥µÄ½â¾ö°ì·¨¡£¹¤·ò²»¸ºÓÐÐÄÈË£¬×îºó£¬ÎÒÖÕÓÚÕÒµ½Á˽â¾öµÄ°ì·¨£¬Ò²¾ÍÊÇÎÒ½«Òª¸ø´ó¼Ò½éÉܵķ½·¨¶þ¡£

¡¡¡¡°²×°ÅäÖ÷½·¨¶þ

¡¡¡¡ÕâÖÖ·½·¨µÄ»ù±¾Ë¼ÏëÊÇ£¬Í¨¹ýRHNÈÃRed Hat×Ô¼º½øÐÐÈí¼þ¸üкÍÒÀÀµÐԵļì²é£¬ÖÁÓÚÈçºÎÉèÖÃRHN£¬Çë²Î¿¼±¾¿¯2003ÄêµÚ1ÆÚ¡°Ê¹ÓÃRHNÈÃRed Hat Linux×Ô¶¯¸üС±µÄÎÄÕ¡£

¡¡¡¡ÔÚRed Hat 8.0ÖУ¬°²×°µÄ²½ÖèÈçÏ£º

¡¡¡¡µÚÒ»²½ up2date mysql mysql-server and mysql-devel

¡¡¡¡Èç¹ûÍøËÙ×ã¹»¿ì£¬ÄÇôÕâ¸ö²½ÖèÒ²²»»á»¨Ì«¶àµÄʱ¼ä¡£ÔÚÎҵĻúÆ÷ÉÏ£¬Õâ¸ö¹ý³ÌÖ»»¨·ÑÁË4·ÖÖÓ£¬Èçͼ3Ëùʾ¡£



¡¡¡¡µÚ¶þ²½ /usr/bin/mysql_install_db

¡¡¡¡µÚÈý²½ chown -R mysql.mysql /var/lib/mysql

¡¡¡¡µÚËIJ½ chmod -R 666 /var/lib/mysql

¡¡¡¡µÚÎå²½ /usr/bin/safe_mysqld-u mysql &

¡¡¡¡µÚÁù²½ up2date unixODBC unixODBC-devel

¡¡¡¡µÚÆß²½ up2date --src MyODBC

¡¡¡¡µÚ°Ë²½ rpmbuild --rebuild /var/spool/up2date/MyODBC-2.50.39-7.src.rpm

¡¡¡¡µÚ¾Å²½ rpm -Uvh --force /usr/src/redhat/RPMS/i386/MyODBC-2.50.39-7.i386.rpm

¡¡¡¡µÚÊ®²½ ²ÎÕÕ·½·¨Ò»±à¼­/etc/odbc.iniºÍ/etc/odbcinst.ini

¡¡¡¡µ«ÊDz»ÖªÊÇʲôԭÒò£¬Ã¿´Îµ±ÎÒʹÓÃup2dateÁбíÖеÄÈí¼þ°üʱ¶¼ÓÐһЩÎÊÌâ¡£Ò²ÐíÊÇijһ´ÎµÄ°²×°¹ý³ÌÖУ¬ÎÒûÓÐÇåÀíºÃϵͳ£¬»òÕßÊǵ±Ä¿Â¼Ê÷ÏÂÓÐÈç´Ë¶àµÄÈí¼þ°üʱ£¬up2dateÎÞ·¨ÕýÈ·Ó¦¶Ô¡£²»¹ÜÔõô˵£¬ÎÒ»¹ÊÇÕýÈ·Íê³ÉÁË°²×°¡£

¡¡¡¡Ð¡½á

¡¡¡¡ÏÖÔÚÔÙÀ´×öÁíÍâÒ»¼þÊÂÇ飬¾ÍÊÇ´Ó¸Õ½¨Á¢µÄ±íÖÐÌáÈ¡ÄÚÈÝ£¬²¢ÇÒ´òÓ¡µØÖ·±êÇ©¡£Íê³ÉÕâ¸ö²½Ö軨·ÑÁËÎÒ´óÁ¿µÄʱ¼ä¡£°´ÕÕ°ïÖúϵͳµÄָʾ£¬ÎÒ´ó¸ÅÁ˽âÁËÅäÖõĹý³Ì£¬µ«ÊÇ×îºóûÓгɹ¦¡£²¢ÇÒ£¬Õâ¸öÅäÖùý³Ì·Ç³£µÄ²»Ö±¹Û£¬¸üºÎ¿öÓеIJ½Öè¸ù±¾¾ÍÎÞ·¨Õý³£¹¤×÷¡£

¡¡¡¡Îª´Ë£¬ÎÒÔÚÍøÉϽøÐÐÁË´óÁ¿¼ìË÷£¬²¢ÇÒ·Ö±ðµ½OpenOffice.orgºÍMySQLµÄÂÛ̳ÖнøÐÐÁËÌáÎÊ£¬µ«ÎÊÌⶼûÓеõ½½â¾ö¡£¹¦·ò²»¸ºÓÐÐÄÈË£¬×îºóÎÒÖÕÓÚ»ñÖªÔ­À´³ö´íµÄÔ­Òò¾ÓÈ»ÊÇOpenOffice.orgµÄ°ïÖúϵͳÎļþµµÓÐһЩ´íÎó¡£ÎÒÖÕÓÚÕÒµ½ÁË¿ÉÒÔÈÃËüÕý³£¹¤×÷µÄ·½·¨¡£

¡¡¡¡µ±ÎÒµÚÒ»´Î³¢ÊÔ´òÓ¡µØÖ·±êǩʱ£¬MySQLÌáʾ³ö´íÐÅÏ¢£º¡°Too many connections.¡±£¬Ô­À´Ò³ÃæÖеÄÿһ¸ö±êÇ©¶¼ÐèÒªÒ»¸ö×Ô¼ºµÄÁ¬½Ó¡£ÓÚÊÇ£¬ÎÒ×öÁËÁ½¼þÊÂÇéÀ´½â¾öÕâ¸öÎÊÌâ¡£Ê×ÏÈ£¬°ÑÏÂÃæÕâЩ¼ÓÈëµ½ÁË/etc/my.cnfµÄMySQLÕ½ÚÖУº

set-variable = max_connections=200



¡¡¡¡ÖÐÖ¹ÁËÕýÔÚÔËÐеĽø³ÌÖ®ºó£¬ÔÚÖØÐÂÆô¶¯Ö®Ç°Ö´ÐÐÁËsu mysql¡£ÎÒÔÚÍøÉÏ¿´µ½ÓÐÒ»¸öMySQL¿ª·¢ÈËÔ±½¨Ò飬Èç¹û²»ÒÔrootÉí·ÝÀ´Æô¶¯mysqldµÄ»°¿ÉÒÔ½â¾ö¡°Too many connection¡±µÄÎÊÌâ¡£ÓÚÊÇÎÒÒÔMySQLµÄÉí·ÝÖØÐÂÆô¶¯ÁËmysql£¬²¢ÇÒÔÚÃüÁîÐÐÖмÓÈëÁËÒ»¸öÓû§²ÎÊý¡£ÕâÑù¸Ä±äÒÔºó£¬Êý¾Ý¿âµÄ·ÃÎʾÍÕý³£ÁË¡£µ±È»£¬µ½µ×ÄÄÒ»¸ö·½·¨ÓÐЧ»¹Òª¾­¹ýһЩʵÑé¡£

¡¡¡¡Õû¸öʹÓùý³ÌÖУ¬ÎҵĸоõÊÇOpenOffice.orgÒªÔ¶±ÈÎÒÏëÏóµÄ¸´ÔÓºÍÇ¿´óµÃ¶à£¬Ëü¿ÉÒԺ͸÷ÖÖÊý¾Ý¿â¹ÜÀíϵͳһÆð¹¤×÷¡£Èç¹ûÄãµÄSOHO°ì¹«»·¾³ÐèÒªÊý¾Ý¿â·ÃÎʺͲÙ×÷£¬ÄÇôÎÒ½¨Òé²»ÒªÂíÉÏÇл»ÖÁOpenOffice.org£¬¶øÊÇÏȶÔÆä½øÐвâÊÔ£¬¿´Ò»¿´ÆäÊÇ·ñ¿ÉÒÔÂú×ãÄãµÄÐèÇó¡£ÐèÒªÖ¸³öµÄÊÇ£¬ÈκÎÈí¼þÎÞÂÛÊÇ´úÂ뻹ÊÇÎĵµ£¬¶¼»áÓÐһЩ´íÎó£¬ËùÒÔ²»Òª¶ÔʹÓùý³ÌÖгöÏÖµÄһЩÎÊÌâ´ó¼Ó±§Ô¹£¬Ó¦¸ÃÒÔ¸ü»ý¼«µÄ̬¶ÈÀ´·¢Ïֺͽâ¾öÎÊÌâ¡£
ÎÄÕÂÆÀÂÛ

¹²ÓÐ 0 ÌõÆÀÂÛ