ubuntu,debian,redhat,fedora,centos
标签类目:MySQL

Eclipse + CDT + MinGW + MySQL环境搭建解决方案

分类:C/C++环境说明: Windows XP, Eclipse 3.5, MinGW 5.1.4, Mysql 5.1.36, CDT 3.1

在Eclipse下用CDT和MinGW编写C访问Mysql时会出现 undefined reference to `mysql_init@4′的问题,这是因为mingw编译时找不到静态库的原因,网上的解决办法一般是用:reimp.exe及dlltool.exe重新生成libmysql.def和libmysql.a,然后用libmysql.a。具体命令是:

dlltool --input-def libmySQL.def --dllname libmySQL.dll --output-lib libmysql.a -k

奇怪的是用这这个办法生成的libmysql.a为0字节,后来查看有libmysql.lib文件,试着将其改名为libmysql.a,问题得到解决,具体解决步骤如下:

1、添加Mysql头文件:
方法1:项目->属性->C/C++ Build->Tool Settings->GCC C Compiler->Directories 中添加你的头文件所在目录,包括Mysql中的include目录。
方法2:将Mysql中的include目录拷到项目下的头文件目录下或MinGW的公共include目录下,目录改名为mysql。

2、添加用于gcc编译的mysql静态库文件
复制mysql安装目录中的\lib\opt\libmysql.lib为libmysql.a。

另外查询或插入记录时乱码问题的解决:
在mysql连接成功后,发出查询之前,加入如下代码

  1. mysql_set_character_set(&mysql,"gb2312");

如有问题,请发邮件到 cdkey51@linuxany.com ,大家一起探讨。

继续阅读 »

Improving Page Load Times(提升页面加载时间)

分类:PHP分类:MySQL分类:ApacheThere are a number of ways to improve the amount of time it takes visitors to load your Drupal powered web site.

Measurements

There are many tools that can be used to measure page load performance on your website. Here are some that we recommend.

  1. YSlow FireFox add-on
    The YSlow FireFox add-on is maintained by Yahoo. It analyses your web page and offers a simple to understand report explaining why your website is slow to load. The tool requires that the Firebug FireFox add-on also be installed. Visit http://developer.yahoo.com/yslow/ for complete details on using the FireFox add-on. 继续阅读 »

MySQL InnoDB Performance Tuning(InnoDB性能调优)

分类:MySQLInnoDB is a transaction-safe, ACID compliant MySQL storage engine. It has commit, rollback, and crash recovery capabilities, and offers row level locking. The engine’s overview page explains, “InnoDB has been designed for maximum performance when processing large data volumes. Its CPU efficiency is probably not matched by any other disk-based relational database engine.” 继续阅读 »

用mysqldumpslow分析MySQL的slow query log

分类:MySQLmysql有一个功能就是可以log下来运行的比较慢的sql语句,默认是没有这个log的,为了开启这个功能,要修改my.cnf或者在mysql启动的时候加入一些参数。如果在my.cnf里面修改,需增加如下几行

long_query_time = 1
log-slow-queries = /var/youpath/slow.log
log-queries-not-using-indexes

long_query_time 是指执行超过多久的sql会被log下来,这里是1秒。
log-slow-queries 设置把日志写在那里,可以为空,系统会给一个缺省的文件host_name-slow.log,我生成的log就在mysql的data目录
log-queries-not-using-indexes 就是字面意思,log下来没有使用索引的query。
继续阅读 »

PhpMyadmin把Mysql5降级导入到Mysql4

分类:PHP分类:MySQL1:用Dreamweaver或者别的代码编辑器打开从Mysql5导出的.sql数据库文件
2:去掉数据库里类似DEFAULT CHARSET=utf8这样的字眼
3:把Mysql数据库里的ENGINE=MyISAM替换成TYPE=MyISAM
4:再用PhpMyadmin导入Mysql4就可以了

返回顶部