有一个查询语句:select * from users where username='ad2008'
第一次查询的时候会比较慢,之后再查询的时候,就比较快,我想可能跟缓存有关系
请问这个结果,mysql缓存到什么地方了,怎样不使用缓存呢?

解决方案 »

  1.   


    show variables like 'have_query_cache';如果结果是YES,代表有高速缓存。
    如果是NO。代表没有
    在my.ini或者my.cnf里配置其是否开启
    [mysqld]
    have_query_cache=no
    关闭。重新启动MYSQL服务器
      

  2.   

    非常感谢,show variables like 'have_query_cache';的结果里是YES,但我在mysql.ini里没有have_query_cache这个选项,然后我手动加在了[mysqld]下面了,可是mysql服务又启不来了
      

  3.   

    答错了。
    看到手册中:o disable the query cache at server startup, set the query_cache_size system variable to 0. By disabling the query cache code, there is no noticeable overhead. If you build MySQL from source, query cache capabilities can be excluded from the server entirely by invoking configure with the --without-query-cache option.所以在你的配置文件里
    [mysqld]
    query_cache_size=0然后重新启动MYSQL服务就可以了