wordpress文章数据库
㈠ wordpress备份数据库文件在哪
进入WordPress管理后台,点击左侧菜单的“工具”--“导出”
2
在导出页面,我们可以选择导出的内容类型,默认是全部内容,然后点击下方的“下载导出的文件”即会下载一个XML文件,这个就是我们备份的文章内容数据,如果需要还原的直接导入即可。
㈡ WordPress本地安装时不能选择数据库,应该怎么设置
需要先创建一个数据库账户,数据库是存储wordpress文章评论用户等数据的,但必须要在本地的mysql管理里面先创建一个mysql账户
然后wordpress安装的时候,填写创建的账户名,数据库名,数据库密码,这样安装程序才能连接到数据库,然后创建对应的数据表存储数据
㈢ wordpress 怎样减少数据库读取量
#1,若您的WordPress版本为2.3及以前,可采用如下方法令系统自动缓存内部调用函数,而完全不用担心缓存对系统交互性的影响(如延迟等)。
Step1:在WordPress安装目录下的wp-content文件夹下创建名为cache的目录,属性设置为755,如下图:
Step2:打开WordPress安装根目录下的wp-config.php文件,在其尾端加入define('ENABLE_CACHE', true);,如下图:
保存后上传更新文件,刷新页面后,可发现新创建的cache文件夹中生成了如下文件:
缓存的是一些不需要经常修改的文件,如分类名称、存档日期等。该缓存方法名为object缓存,并不缓存网页,而传统的wp-cache调用是缓存网页的,会影响网页的交互实时性,使用户体验些许变差。
#2,若您的WordPress版本为2.5及以上版本,由于新版WP取消了object缓存功能可以使用将所有待查数据都存入数据库options表(一般的默认名称为wp_options)的方法,大幅度减少数据库查询次数。ThinkAgain的解释如下:
默认WP有10个数据表,wp_posts和comments主要存储文章内容和评论,
其它的几个包括term等存储了目录和标签等等。这里不细谈。wp_options用来存储Wordpress以及插件运行时所涉及的配置等。且WP会在
运行时自动读取该表的内容。换句话说,因为WP已经预读这部分内容,所以直接调用wp_options内的数据是不会产生数据库查询的。(http://www.thinkagain.cn/archives/969.html)
方法:假如要缓存的是分类名称调用表单,则写functions.php如下代码:
function cache_category(){
$cached = get_option('multicolor_cache_category');
if($cached){
echo $cached;
}else{
$cached = cache_collapsible_list_cats();
echo "Update cache";
echo $cached;
}
}
add_action('publish_post', 'cache_collapsible_list_cats');
当然,这显得很复杂,不过ThinkAgain说,WP2.6也是可以使用object自动缓存功能的,请等待他更新的方法。
#3,由于WordPress的内部永久链接调用函数为了追求老版插件的最大兼容性所以较啰嗦,比较耗费查询次数,可在functions.php写入如下代码,大幅度减少查询次数(均适用)
function revised_permalink($post, $leavename=false) {
$rewritecode = array(
'%year%',
'%monthnum%',
'%day%',
'%hour%',
'%minute%',
'%second%',
$leavename? '' : '%postname%',
'%post_id%',
'%category%',
'%author%',
$leavename? '' : '%pagename%',
);
if ( empty($post->ID) ) return FALSE;
if ( $post->post_type == 'page' )
return get_page_link($post->ID, $leavename);
elseif ($post->post_type == 'attachment')
return get_attachment_link($post->ID);
$permalink = get_option('permalink_structure');
if ( '' != $permalink && !in_array($post->post_status, array('draft', 'pending')) ) {
$unixtime = strtotime($post->post_date);
$category = '';
if ( strpos($permalink, '%category%') !== false ) {
$cats = get_the_category($post->ID);
if ( $cats )
usort($cats, '_usort_terms_by_ID'); // order by ID
$category = $cats[0]->slug;
if ( $parent=$cats[0]->parent )
$category = get_category_parents($parent, FALSE, '/', TRUE) . $category;
// show default category in permalinks, without
// having to assign it explicitly
if ( empty($category) ) {
$default_category = get_category( get_option( 'default_category' ) );
$category = is_wp_error( $default_category ) ? '' : $default_category->slug;
}
}
$author = '';
if ( strpos($permalink, '%author%') !== false ) {
$authordata = get_userdata($post->post_author);
$author = $authordata->user_nicename;
}
$date = explode(" ",date('Y m d H i s', $unixtime));
$rewritereplace =
array(
$date[0],
$date[1],
$date[2],
$date[3],
$date[4],
$date[5],
$post->post_name,
$post->ID,
$category,
$author,
$post->post_name,
);
$permalink = get_option('home') . str_replace($rewritecode, $rewritereplace, $permalink);
$permalink = user_trailingslashit($permalink, 'single');
return apply_filters('post_link', $permalink, $post);
} else { // if they're not using the fancy permalink option
$permalink = get_option('home') . '/?p=' . $post->ID;
return apply_filters('post_link', $permalink, $post);
}
}
点击下面的链接下载修改好的文件,请解压后上传或粘贴到您原来的文件中。此方法文章页查询次数至少可降低10。
注意:如果您原来的插件有诸如下面的代码,并且您的永久链接方式为postname而不是postid,请修改
$sql = "SELECT ID, post_title, comment_count,post_date, post_content FROM $tableposts WHERE post_status = 'publish' ";
为
$sql = "SELECT ID, post_name, post_title,
comment_count,post_date, post_content FROM $tableposts WHERE
post_status = 'publish' ";
至此您的数据库查询次数将减小为个位数,繁忙时访问速度提高较显着,速度应当与直接生成静态文件时的情况差距不大,但互动性丝毫不减。
㈣ 新手wordpress的数据库空间一般要多大够用
看你是什么主题的博客,是否是文章居多,或者是图片居多,文章的话,300M,图片的话可以买500M就够用了,普通博客文章较多,占用的空间不会太大,如果发展的很好,那到时候可以迁移新的服务器就可以了。