php-mysql-101-questions

MySQL 5.1 Appendix B. Error Codes and Messages

超越 PHPwww.phpe.net   最新最完全的PHP來源,包括線上說明,技術手冊,文章、 PHP Developer Channel :: 討論園地www.phpdc.com    PHP Developer Channel     JavaScript Guide(英)      phpMyadmin相關教學            天新網 MySQL文章一個 PHP 資源豐富的站台,只要你能接受簡體字和大陸術語的不同   電算中心(GB)     PHP5網管實驗室   PHP 的入口網站,新聞、專欄、提供PHP、MySQL、Linux 相關教學、 討論區、PHP相關性技術及原始碼整理分類下載 範例檔下載    PostgreSQL 7.3 文档       Apache2英文参考手册    中國PHP聯盟www.phpx.com       MySQL5英文参考手册      frequently-asked-questions

本手册主要由函数参考组成,但也包括语言参考,PHP 一些主要特点的说明以及其它补充信息

可以在 /download-docs.php 下载本手册的数种格式。关于本手册如何被开发的更多信息,请参阅附录:“关于本手册”。如果对 PHP 的历史感兴趣,请访问相关附录。



      

10.4. Connection Character Sets and Collations   MySQL 字型和連線校對(排序)   中文亂碼的問題

怎么才能正确配置PHP+MySQL,让它能支持中文呢?  要明白中文亂碼的問題 必須明白的這一課.........more

utf8字符集是一张非常巨大的表格,把世界上各种语言的字符和标点符号都编排到里面.........more

显示中文乱码有时是在IE或FireFox里运行就出现乱码,这与 Apache Server 配置有关.............more

MySQL server在远方MySQL server的my.ini 不在你的掌控下, 你就只能用PHP 去控制 MySQL server

重要的例子說明 No need here for a <? mysql_query("SET NAMES utf8"); ?> ................ For more examples see PHP手册

# 建立 MySQL資料庫的第一步 指定字型(character set)
服务器级server-level字符集(character set)和 排序(Collation)

CREATE DATABASE db_name
    [[DEFAULT] CHARACTER SET charset_name]
    [[DEFAULT] COLLATE collation_name]
	

選擇MySQL資料庫字集和排序collation的方法

如果你不指定(specify)字符集,默认就是说--character-set-server=latin1

数据库的默认字符集(default character set) 和 排序(collation) 是被 character_set_databasecollation_database这两个系统变量system variables的值決定,
If there is no 默认数据库的值, 就继承server-level 的系统变量system variables..........more

MySQL語言結構Language Structure 文字:怎麼寫字串string

The following SELECT statements demonstrate how quoting and escaping work:
下面顯示的SELECT展示引號和轉義如何工作:...................more

mysql> SELECT 'hello', '"hello"', '""hello""', 'hel''lo', '\'hello';
+-------+---------+-----------+--------+--------+
| hello | "hello" | ""hello"" | hel'lo | 'hello |
+-------+---------+-----------+--------+--------+

mysql> SELECT "hello", "'hello'", "''hello''", "hel""lo", "\"hello";
+-------+---------+-----------+--------+--------+
| hello | 'hello' | ''hello'' | hel"lo | "hello |
+-------+---------+-----------+--------+--------+

# 10.3.7. Examples of Character Set and Collation Assignment

CREATE DATABASE d1
    DEFAULT CHARACTER SET latin2 COLLATE latin2_czech_ci;
USE d1;
CREATE TABLE t1
(
    c1 CHAR(10)
);

当我们建立一个新的 列(column) 和 表(table),若未明确指定(specifying) 字符集(character set) 和排序( collation), MySQL 会检查 database层 而决定.....

例子显示了 MySQL 怎样决定默认的字符集character set和排序collation的值........more

 

对于已有的数据库可以用以下方法转换字 编码:
MySQL 5.0 Reference Manual :: 13.1.2 ALTER TABLE Syntax

MySQL 5.0 Reference Manual :: 13.1.1 ALTER DATABASE Syntax

10.1. Character Sets and Collations in General

MySQL 字型和連線校對(排序)

MySQL 字符集 排序

MySQL 服务器可支持多个字符集。要列出可用的字符集,使用SHOW CHARACTER SET 语句

Collation在phpMyAdmin 翻成中文是 MySQL 連線校對,MySQL 连接校对
中文字型collation(排序)由筆劃多少決定 例如下表 : 周,林 都是8筆 , 再比第2字........ 由SELECT語句的ORDER BY和GROUP BY子句 排序..............more

5.11.7. Problems With Character Sets

If you try to use a character set that is not compiled into your binary, you might run into the following problems:...........more

 

describes the meaning of these variables........Section 5.2.2, “Server System Variables”

MySQL 5.0 Reference Manual :: 13 SQL Statement Syntax :: 13.5 Database Administration Statements :: 13.5.4 SHOW Syntax

SHOW has many forms that provide information about databases, tables, columns, or status information about the server. This section describes those following:

SHOW [FULL] COLUMNS FROM tbl_name [FROM db_name] [LIKE 'pattern']
SHOW CREATE DATABASE db_name
SHOW CREATE FUNCTION funcname
SHOW CREATE PROCEDURE procname
SHOW CREATE TABLE tbl_name
SHOW DATABASES [LIKE 'pattern']
SHOW ENGINE engine_name {LOGS | STATUS }
SHOW [STORAGE] ENGINES
SHOW ERRORS [LIMIT [offset,] row_count]
SHOW FUNCTION STATUS [LIKE 'pattern']
SHOW GRANTS FOR user
SHOW INDEX FROM tbl_name [FROM db_name]
SHOW INNODB STATUS
SHOW PROCEDURE STATUS [LIKE 'pattern']
SHOW [BDB] LOGS
SHOW PRIVILEGES
SHOW [FULL] PROCESSLIST
SHOW [GLOBAL | SESSION] STATUS [LIKE 'pattern']
SHOW TABLE STATUS [FROM db_name] [LIKE 'pattern']
SHOW [OPEN] TABLES [FROM db_name] [LIKE 'pattern']
SHOW TRIGGERS
SHOW [GLOBAL | SESSION] VARIABLES [LIKE 'pattern']
SHOW WARNINGS [LIMIT [offset,] row_count]..............into

GLOBAL and SESSION

The options GLOBAL and SESSION are new in MySQL 4.0.3. With GLOBAL you will get the variables that will be used for new connections to MySQL. With SESSION you will get the values that are in effect for the current connection. If you are not using either option, SESSION is used.
init_file The name of the file specified with the --init-file option when you start the server. This is a file of SQL statements you want the server to execute when it starts.

GLOBAL variables affect the overall operation of the server.
SESSION variables affect its operation for individual client connections.
The server also maintains a set of SESSION variables for each client that connects. The client's SESSION variables are initialized at connect time using the current values of the corresponding GLOBAL variables.........more
With SESSION, it displays the values that are in effect for the current connection. If no modifier is present, the default is SESSION. LOCAL is ...........more

4.3.2. Using Option Files(also sometimes called configuration files)

使用設置檔   my.ini    my.cnf

Most MySQL programs can read startup options from option files (also sometimes called configuration files). Option files provide a convenient way to specify commonly used options so that they need not be entered on the command line each time you run a program.

原网址 :http://dev.mysql.com/doc/refman/5.0/en/option-files.html

9.2.1 Identifier Qualifiers10.1 合格的 標識 , 名字 命名規則

如果 任何 多部分 名字(multiple-part name) 要求 用引号要quoting 是 `database-name`.`my-table`.`my-column`不是 `database-name.my-table.my-column`请注意 是`(This character is under Esc ,above Tab )不是    ' (next to Enter)

 

建立和使用MySQL資料庫 請注意:PHP程式 MySQL database常見錯誤 問題.......more

MySQL What's point ? 这点 ` 或 那点 ' 

:PHP程序 MySQL database常见错误 问题 9.2.1 Identifier Qualifiers10.1 合格的 标识 , 名字...........more

 

After creating your table, you need to populate it. The LOAD DATA and INSERT statements are useful for this...........more

转移MySQL 4.0到MySQL 4.1    Migrating from 4.0 to 4.1

在网页上处理 UTF-8 data 相当简单,你只要网页 <head>或 body指示character set :

<?php header("Content-type: text/html; charset=utf-8");?>
<html>
 <head>
  <meta http-equiv="Content-type" value="text/html; charset=utf-8">
  ...

升级成MySQL 4.1後 要让 MySQL Server 知道 栏(column)的 true character set
但 如果你只是作 ALTER TABLE myTable MODIFY myColumn VARCHAR(255) CHARACTER SET utf8 ,MySQL Server会试着 把 myColumn栏(column) 从 MySQL Server默认字集 转换成UTF-8.你需要作一转换:

ALTER TABLE myTable MODIFY myColumn BINARY(255);
 ALTER TABLE myTable MODIFY myColumn VARCHAR(255) CHARACTER SET utf8;

For more detail
10.9.2. Converting 4.0 Character Columns to 4.1 Format

 

mm