ubuntu安装mysql++
2013-10-23 14:22
218 查看
1. 首先安装mysql数据库。
sudo apt-get install mysql-server
安装过程中,会要求你输入root的密码,这个密码是以后mysql的超级用户密码。
2. 上mysql++官网http://tangentsoft.net/mysql++/下载最新的mysql++稳定版。(解压之后,记得读README*.txt,很重要,里面讲了很多关于系统和怎么安装的问题)
mysql++-3.2.0.tar.gz (2.1 MB, 2013.06.20) — Library source code.
下载完成之后,解压。然后安装。
tar xzvf mysql++-3.2.0.tar.gz
sudo ./configure --help #首先 查看其configure的help命令
接着运行
sudo ./configure
但是出现了下面的错误:
checking for MySQL library directory... configure: error: Didn't find
mysqlclient library in '/usr/lib64 /usr/lib /usr/lib64/mysql /usr/lib/mysql
/usr/local/lib64 /usr/local/lib /usr/local/lib/mysql /usr/local/mysql/lib
/usr/local/mysql/lib/mysql /usr/mysql/lib/mysql /opt/mysql/lib
/opt/mysql/lib/mysql /sw/lib /sw/lib/mysql'
这里的解决:
首先查找本地libmysqlclient的目录在哪里,在终端敲下面的命令
locate libmysqlclient (注意,在使用locate命令时,要先sudo updatedb一下,因为locate是一天更新一次db,一天之内新增的东西,locate就定位不到,udatedb一下就可以了)
得到
![](http://img2.ph.126.net/bNC4hW61wvFP_iOZrBvIQQ==/3893643352938904382.jpg)
于是
sudo ./configure --with-mysql-lib=/usr/lib/x86_64-linux-gnu
如果还出现上述问题,安装libmysqlclient-dev
sudo apt-get install libmysqlclient-dev
如果mysql的安装路径不是在/usr 下,还会出现下列错误
Didn't find the mysql in ......
这是用--with-mysql-include选项进行安装,比如我的mysqlclient lib在/opt/local/lib/mysql5/mysql, 而mysql 在/opt/local/include/mysql5/mysql,则用下列命令安装一遍即可。
sudo ./configure --with-mysql-lib=/opt/local/lib/mysql5/mysql/ --with-mysql-include=/opt/local/include/mysql5/mysql/
接下去
sudo make
sudo make install
************************************************************************
安装完成之后,我们要运行一个helloworld程序。
#include <mysql++.h>
int main()
{
mysqlpp::String greeting("Hello, world!");
std::cout << greeting << std::endl;
return 0;
}
然后编写相应的makefile
CXXFLAGS := -I/usr/include/mysql -I/usr/local/include/mysql++LDFLAGS := -L/usr/local/libLDLIBS := -lmysqlpp -lmysqlclientEXECUTABLE := mysqlplusplus_helloworld
all: $(EXECUTABLE)
clean: rm -f $(EXECUTABLE) *.o
make, ./mysqlplusplus_helloworld
运行一般可以成功。
如果出现如下错误,可以试试 sudo ldconfig ,再试一次。
./mysqlplusplus_helloworld: error while loading shared libraries: libmysqlpp.so.3: cannot open shared object file: No such file or directory
我们需要在/etc/ld.so.conf文件中,添加include /usr/local/lib,采用tee追加方式
echo "include /usr/local/lib" |sudo tee -a /etc/ld.so.confsudo ldconfig #使其生效。
sudo apt-get install mysql-server
安装过程中,会要求你输入root的密码,这个密码是以后mysql的超级用户密码。
2. 上mysql++官网http://tangentsoft.net/mysql++/下载最新的mysql++稳定版。(解压之后,记得读README*.txt,很重要,里面讲了很多关于系统和怎么安装的问题)
mysql++-3.2.0.tar.gz (2.1 MB, 2013.06.20) — Library source code.
下载完成之后,解压。然后安装。
tar xzvf mysql++-3.2.0.tar.gz
sudo ./configure --help #首先 查看其configure的help命令
接着运行
sudo ./configure
但是出现了下面的错误:
checking for MySQL library directory... configure: error: Didn't find
mysqlclient library in '/usr/lib64 /usr/lib /usr/lib64/mysql /usr/lib/mysql
/usr/local/lib64 /usr/local/lib /usr/local/lib/mysql /usr/local/mysql/lib
/usr/local/mysql/lib/mysql /usr/mysql/lib/mysql /opt/mysql/lib
/opt/mysql/lib/mysql /sw/lib /sw/lib/mysql'
这里的解决:
首先查找本地libmysqlclient的目录在哪里,在终端敲下面的命令
locate libmysqlclient (注意,在使用locate命令时,要先sudo updatedb一下,因为locate是一天更新一次db,一天之内新增的东西,locate就定位不到,udatedb一下就可以了)
得到
![](http://img2.ph.126.net/bNC4hW61wvFP_iOZrBvIQQ==/3893643352938904382.jpg)
于是
sudo ./configure --with-mysql-lib=/usr/lib/x86_64-linux-gnu
如果还出现上述问题,安装libmysqlclient-dev
sudo apt-get install libmysqlclient-dev
如果mysql的安装路径不是在/usr 下,还会出现下列错误
Didn't find the mysql in ......
这是用--with-mysql-include选项进行安装,比如我的mysqlclient lib在/opt/local/lib/mysql5/mysql, 而mysql 在/opt/local/include/mysql5/mysql,则用下列命令安装一遍即可。
sudo ./configure --with-mysql-lib=/opt/local/lib/mysql5/mysql/ --with-mysql-include=/opt/local/include/mysql5/mysql/
接下去
sudo make
sudo make install
************************************************************************
安装完成之后,我们要运行一个helloworld程序。
#include <mysql++.h>
int main()
{
mysqlpp::String greeting("Hello, world!");
std::cout << greeting << std::endl;
return 0;
}
然后编写相应的makefile
CXXFLAGS := -I/usr/include/mysql -I/usr/local/include/mysql++LDFLAGS := -L/usr/local/libLDLIBS := -lmysqlpp -lmysqlclientEXECUTABLE := mysqlplusplus_helloworld
all: $(EXECUTABLE)
clean: rm -f $(EXECUTABLE) *.o
make, ./mysqlplusplus_helloworld
运行一般可以成功。
如果出现如下错误,可以试试 sudo ldconfig ,再试一次。
./mysqlplusplus_helloworld: error while loading shared libraries: libmysqlpp.so.3: cannot open shared object file: No such file or directory
我们需要在/etc/ld.so.conf文件中,添加include /usr/local/lib,采用tee追加方式
echo "include /usr/local/lib" |sudo tee -a /etc/ld.so.confsudo ldconfig #使其生效。
相关文章推荐
- ubuntu16.04 安装mysql 5.7.x 报错解决
- ubuntu安装EnvironmentError: mysql_config not found错误
- ubuntu下mysql安装路径更改及密码修改
- ubuntu14.04上安装Mysql-5.7.11
- ubuntu安装mysql
- Linux(Ubuntu)下MySQL的安装与配置
- ubuntu14.04 安装 Mysql-connector-Pyhon
- Linux(Ubuntu)下MySQL的安装与配置
- Ubuntu 安装mysql和简单操作
- Ubuntu安装mysql
- Ubuntu 16.04 LTS (LEMP) 安装 Nginx/PHP 7/MySQL 5.7
- ubuntu中mysql的安装与卸载
- Ubuntu下MySQL安装
- ubuntu15.04中安装mysql和mysql-workbench
- 如何在UBUNTU中安装MYSQL
- Ubuntu下安装Mysql(5.5)和主从功能配置
- ubuntu上在线安装mysql
- MySql通用二进制版本在Linux(Ubuntu)下安装与开启服务
- ubuntu下MySQL的安装及远程连接配置
- ubuntu下安装mysql 报错