Home > Tags > mysql
mysql
CentOS4でMySQL5をbuildするとDBD::mysqlエラーが起こる。
CentOS4にMySQL5を入れて、
mysqlhotcopyをすると
install_driver(mysql) failed: Can't load '/usr/local/src/DBD-mysql-4.005/blib/arch/auto/DBD/mysql/mysql.so' for module DBD::mysql: libmysqlclient.so.15: cannot open shared object file: No such file or directory at /usr/lib/perl5/5.8.5/i386-linux-thread-multi/DynaLoader.pm line 230.
とエラーを吐く。
DBD::mysql-4.004をインストールし直す。4.004以上を入れると何かとエラーを起こすようなので4.004をインストールすること。
その前に、
# vi /etc/ld.so.conf
/usr/local/mysql/lib/mysql
と編集する。
そして、
# /sbin/ldconfig
とする。
perl Makefile.PL --cflags="-I/usr/local/mysql/include/mysql" --libs="-L/usr/local/mysql/lib/mysql -lmysqlclient -lz -lcrypt -lnsl -lm" --testhost="localhost" --testuser="root" --testpassword='123456' --testdb="mysql"
のように指定。
あとは、make,make install
これでmysqlhotcopyが動くようになった。
↓がバックアップスクリプト
#!/bin/bash
PATH=/usr/local/mysql/bin:/usr/local/sbin:/usr/bin:/bin
BACKDIR=/backup/mysql
ROOTPASS=123456
rm -rf $BACKDIR
mkdir -p $BACKDIR
DBLIST=`ls -p /usr/local/mysql/var | grep / | tr -d /`
for dbname in $DBLIST
do
table_count=`mysql -u root -p$ROOTPASS -B -e "show tables" $dbname|wc -l`
[ $table_count -ne 0 ] &&
mysqlhotcopy $dbname -u root -p $ROOTPASS $BACKDIR | logger -t mysqlhotcopy
done
- Comments: 0
- Trackbacks: 0
rubygems - mysqlアダプタがインストール出来ない
mac OSX 10.4 にgemでmysql2.7のネイティブアダプタがインストール出来ない場合。
sudo gem install mysql — –with-mysql-dir=/usr/local/mysql
Select which gem to install for your platform (i686-darwin8.11.1)
1. mysql 2.7.3 (mswin32)
2. mysql 2.7.1 (mswin32)
3. mysql 2.7 (ruby)
4. mysql 2.6 (ruby)
5. Skip this gem
6. Cancel installation
> Building native extensions. This could take a while…
ERROR: While executing gem … (Gem::Installer::ExtensionBuildError)
ERROR: Failed to build gem native extension.
ruby extconf.rb install mysql — –with-mysql-dir=/usr/local/mysql
checking for mysql_query() in -lmysqlclient… yes
checking for mysql_ssl_set()… yes
checking for mysql.h… yes
creating Makefile
make
gcc -I. -I. -I/opt/local/lib/ruby/1.8/i686-darwin8.11.1 -I. -DHAVE_MYSQL_SSL_SET -DHAVE_MYSQL_H -I/usr/local/mysql/include -I/opt/local/include -fno-common -O2 -fno-common -pipe -fno-common -c mysql.c
mysql.c: In function ‘query’:
mysql.c:635: error: invalid storage class for function ‘res_free’
mysql.c:637: error: ‘res_free’ undeclared (first use in this function)
mysql.c:637: error: (Each undeclared identifier is reported only once
mysql.c:637: error: for each function it appears in.)
mysql.c: In function ‘Init_mysql’:
mysql.c:1299: error: ‘ulong’ undeclared (first use in this function)
mysql.c:1299: error: parse error before numeric constant
mysql.c:1302: error: parse error before numeric constant
make: *** [mysql.o] Error 1
Gem files will remain installed in /opt/local/lib/ruby/gems/1.8/gems/mysql-2.7 for inspection.
Results logged to /opt/local/lib/ruby/gems/1.8/gems/mysql-2.7/gem_make.out
と、エラーを吐く。
以下、解決法↓
sudo vim /opt/local/lib/ruby/gems/1.8/gems/mysql-2.7/mysql.c.in.
ファイル先頭に
#define ulong unsigned long
と記述。
cd /opt/local/lib/ruby/gems/1.8/gems/mysql-2.7
sudo ruby extconf.rb –with-mysql-config=/usr/local/mysql/bin/mysql_config
sudo make
sudo make install
以上。メモ。
- Comments: 0
- Trackbacks: 0
Home > Tags > mysql
- Search
- Feeds
- Meta