Posts tagged MySQL
把wordpress搬到nginx环境
Sep 9th
这次并不是换了博客的宿主,而是更换了博客的主机(VPS)。换到国外的服务器去了,虽然响应时间慢了点,但整体的速度要比以前的虚拟主机要快。
这次搬家的过程中,碰到了些容易出现的问题。
比如MySQL数据库的编码问题,这个配置MySQL的时候,要注意增加配置
[client] default-character-set = utf8 [mysqld] default-character-set = utf8
下面的这些语句可能对你有用:
alter database blog character set utf8; create database mydb character set utf-8; SHOW VARIABLES LIKE 'character_set_%'; SHOW VARIABLES LIKE 'collation_%';
当然在配置Nginx上也要注意一个地方,这样就支持了wordpress的伪静态
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
server {
listen 80;
server_name www.herbertyang.com;
access_log logs/blog.access.log main;
location / {
add_header Content-Type "text/html; charset=UTF-8";
add_header Content-Encoding "gzip";
try_files $uri $uri/ /index.php?q=$uri&$args;
root /home/app/phproot/wordpress;
index index.php index.html index.htm;
}
location ~* \.(jpg|jpeg|png|gif|css|js|swf|mp3|avi|flv|xml|zip|rar)$ {
expires 30d;
gzip on;
gzip_types text/plain application/x-javascript text/css application/xml;
root /home/app/phproot/wordpress;
}
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /home/app/phproot/wordpress$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
}
最后也把Wordpress加上了Memcached,速度还是快了一点,响应的速度有点慢,不过感觉流畅很多。
参考网址:
http://blog.s135.com/nginx_php_v6/
http://www.23day.com/html/22890.html
http://www.nonabyte.net/nginx-wordpress-rewrite/
批量删除某个前缀的表[MySQL]
Apr 9th
由于本站点尝试过安装了BBS和其它一个博客,但又被我卸载了,现在想把这些有特殊前缀的表全部删掉。好像MySQL本身没有这个功能,所以找方法取而代之。
先运行下面的SQL语句:
select concat('drop table ', table_name, ';') from information_schema.tables where table_name like 'bbs_%';
然后得到一个drop table bbs_* 的列表,很简单了,到控制台跑一遍就可以了。