重設 mysql table auto_increment 初值

出至:http://ariejan.net/2007/11/30/mysql-reset-the-auto-increment-value-of-a-table/

MySQL: (Re)set the auto-increment value of a table
Written by Ariejan de Vroom on 30 November 2007.

via Ad Packs
Sometimes it’s necessary to set the starting point of a MySQL auto-increment value.

Normally, MySQL starts auto-incrementing at 1. But let’s say you want to start at 10.000, because you want at least a five figure number. You can use the following query to set the MySQL auto-index:

ALTER TABLE some_table AUTO_INCREMENT=10000

If you want to delete all records from your table and restart auto-index at 1, you might be tempted to run a DELETE query, followed by the above example, setting the auto increment value to 1. There is a shortcut, however:

TRUNCATE TABLE some_table

This will basically reset the table, deleting all data and resetting the auto increment index. Do not that the truncate command is a hard-reset option. For instance, any triggers “ON DELETE” will not be fired when using truncate.

mysql foreign key ,使用 InnoDB engine。預設是 MYISAM

出至:http://dev.mysql.com/doc/refman/5.5/en/storage-engine-setting.html

14.1. Setting the Storage Engine
When you create a new table, you can specify which storage engine to use by adding an ENGINE table option to the CREATE TABLE statement:

CREATE TABLE t (i INT) ENGINE = INNODB;

If you omit the ENGINE option, the default storage engine is used. The default engine is InnoDB as of MySQL 5.5.5 (MyISAM before 5.5.5). You can specify the default engine by using the –default-storage-engine server startup option, or by setting the default-storage-engine option in the my.cnf configuration file.

使用 mysql_real_escape_string 函式,處理 新增、更新字串中包含的特殊字元。

有時在PHP上做Mysql資料庫操作時會遇到在插入的字串之中,包含一些特殊字元(例如:’,",\)的符號。而這些字元通常會讓sql的操作出錯誤,因此在更新或插入資料前會將資料字串中的特殊字元先「escapse」掉。

當然我們可以自已寫個relace函式來取代這此特殊字元符號(String Literals)。或是利用現成的 mysql_real_escape_string 函式,簡簡單單將包含特殊字元的字串丟進去,就會自動將處理後的字串值輸出。

How to install wordpress on windows XP

如何在windows XP 上安裝wordpress, 按照wordpress官方的說法:主機必需要安裝php和mysql。

如果你的系統尚未安裝php和mysql的話,可以下載安裝WampServer這是php和mysql的整合安裝包。

其實安裝wordpress很簡單只要參照wordpress安裝說明來做應該都可以很快就安裝完成了,安裝說明頁面 WordPress安裝|WordPress中文指南
繼續閱讀