CentOS下安装启动MySQL及调用QT
一、安装,启动mySQL:
1、CentOS中如果已经有了mySQL
/etc/rc.d/init.d/./mysqld start (启动mySQL, 此时可以运行mySQL -root)
编辑rc.local文件 #vi /etc/rc.d/rc.local
加入如下启动命令
/etc/rc.d/init.d/mysqld start
(mySQL 开机自动启动)
2、如果没有安装:
1>、yum install mysql,
安装后 需要重复 1 的步骤 设置开机自动重启;
2>、 p { margin-bottom: 0.08in; }
For CentOS 32-bit system: Get rpm
wget http://mysql.mirrors.pair.com/Downloads/MySQL-5.0/MySQL-server-community-5.0.92-1.rhel5.i386.rpm
wget http://mysql.mirrors.pair.com/Downloads/MySQL-5.0/MySQL-client-community-5.0.92-1.rhel5.i386.rpm
wget http://mysql.mirrors.pair.com/Downloads/MySQL-5.0/MySQL-devel-community-5.0.92-1.rhel5.i386.rpm
wget http://mysql.mirrors.pair.com/Downloads/MySQL-5.0/MySQL-shared-community-5.0.92-1.rhel5.i386.rpm
wget http://mysql.mirrors.pair.com/Downloads/MySQL-5.0/MySQL-shared-compat-5.0.92-1.rhel5.i386.rpm
p { margin-bottom: 0.08in; }
wget http://mysql.mirrors.pair.com/Downloads/MySQL-5.0/MySQL-server-community-5.0.92-1.rhel5.x86_64.rpm
For CentOS 64-bit system: Get rpm
p { margin-bottom: 0.08in; }
wget http://mysql.mirrors.pair.com/Downloads/MySQL-5.0/MySQL-server-community-5.0.92-1.rhel5.x86_64.rpm
wget http://mysql.mirrors.pair.com/Downloads/MySQL-5.0/MySQL-client-community-5.0.92-1.rhel5.x86_64.rpm
wget http://mysql.mirrors.pair.com/Downloads/MySQL-5.0/MySQL-devel-community-5.0.92-1.rhel5.x86_64.rpm
wget http://mysql.mirrors.pair.com/Downloads/MySQL-5.0/MySQL-shared-community-5.0.92-1.rhel5.x86_64.rpm
wget http://mysql.mirrors.pair.com/Downloads/MySQL-5.0/MySQL-shared-compat-5.0.92-1.rhel5.x86_64.rpm
Install
rpm -iUvh MySQL-server-community-5.0.92-1.rhel5.i386.rpm
rpm -iUvh MySQL-client-community-5.0.92-1.rhel5.i386.rpm
rpm -iUvh MySQL-devel-community-5.0.92-1.rhel5.i386.rpm
rpm -iUvh MySQL-shared-community-5.0.92-1.rhel5.i386.rpm
rpm -iUvh MySQL-shared-compat-5.0.92-1.rhel5.i386.rpm
rpm包安装会设置开机自动重启,不需要重复1的步骤。
二、编译安装mysql 使Qt能调用。 p { margin-bottom: 0.08in; }
export PATH=/opt/qtsdk-2010.04/qt/bin:$PATH
cd /opt/qtsdk-2010.04/qt/src/plugins/sqldrivers/mysql/
for 32-bit:
qmake -o Makefile 'INCLUDEPATH+=/usr/include/mysql' 'LIBS+=-L/usr/lib/mysql' mysql.pro
for 64-bit
qmake -o Makefile 'INCLUDEPATH+=/usr/include/mysql' 'LIBS+=-L/usr/lib64 /mysql' mysql.pro
make
cp libqsqlmysql.so ../../../../plugins/sqldrivers/
如果在qmake时候提示:qpluginbase.pri:10: Unknown replace function: qtLibraryTarget
则是因为export PATH=/opt/qtsdk-2010.04/qt/bin:$PATH 参数(path)错误
如果在make时候提示:../../../sql/drivers/mysql/qsql_mysql.h:52:19: error: mysql.h: No such file or directory
缺少mysql-devel
yum install mysql-devel
重新make