易截截图软件、单文件、免安装、纯绿色、仅160KB

利用Federated引擎进行mysql复制

Accessing Distributed Data with the Federated Storage Engine
http://dev.mysql.com/tech-resources/articles/mysql-federated-storage.html
Federated存储引擎可以使几台数据库逻辑上组成一个数据库,其作用相当于Oracle的数据库链接,通俗地说,即在本地建立远程的数据库表的引用。
Mysql需要5.0以上
(1)查看是否安装了federated引擎
show engines;
Engine Support Comment Transactions XA Savepoints
MEMORY YES Hash based, stored in memory, useful for temporary tables NO NO NO
FEDERATED NO Federated MySQL storage engine   
MyISAM YES Default engine as of MySQL 3.23 with great performance NO NO NO
BLACKHOLE YES /dev/null storage engine (anything you write to it disappears) NO NO NO
MRG_MYISAM YES Collection of identical MyISAM tables NO NO NO
CSV YES CSV storage engine NO NO NO
ARCHIVE YES Archive storage engine NO NO NO
InnoDB DEFAULT Supports transactions, row-level locking, and foreign keys YES YES YES
从中可以看出federated引擎没有开启
windows下在my.ini中加入federated,即可开启;而在linux中,需要编译时加入选项,再在my.ini中加入federated,即可开启。
(2)建立远程数据库表链接
比如:在server1中有一个数据库db1,在server2中有db1,其中server1.db1为写,server.db1为备份;假设在两个服务器db1中分别有一个表a,在server1.db1中建立server2.db1.a的链接
create table remote_a ...... engine=federated connection = 'mysql://root:123456@server2:3306/db1/a';
(3)创建触发器
delimiter ;;
create trigger copy_a_insert after insert on a for each row begin 向remote_a插入数据 end;;
create trigger copy_a_update after update on a for each row begin 向remote_a更新数据 end;;
create trigger copy_a_delete after delete on a for each row begin 向remote_a删除数据 end;;
delimiter ;
这样在向server1.db1.a中插入数据时,调用触发器copy_a_insert,向remote_a插入数据,而remote_a是对serve


相关文档:

Mysql乱码

PHP 存取 MySQL 乱码问题
上一篇 / 下一篇  2007-06-04 03:33:50 / 个人分类:PHP学习
查看( 239 ) / 评论( 0 ) / 评分( 0 / 0 )
MySQL 的字符集支持(Character Set Support)有两个方面:字符集(Character set)和排序方式(Collation)。对于字符集的支持细化到四个层次: 服务器(server),数据库(database),数据表 ......

Mysql数据库用户认证的问题


这时间在安装PHPBB的论坛,发现一个问题,那就是输入用户名跟密码后,点击安装,总是报了以下的错误:
 程序代码
ORA-28008: invalid old password
Cause: old password supplied is wrong; Hence user cannot be authenticated using old password
Action: Supply the correct old password for authenticatio ......

由浅入深讲解MySQL数据库索引的选择性 数据库索引

在MySQL中,对于索引的使用并是一直都采用正确的决定。
  简单表的示例:
  create TABLE `r2` (
  ID` int(11) DEFAULT NULL,
  ID1` int(11) DEFAULT NULL,
  CNAME` varchar(32) DEFAULT NULL,
  KEY `ID1` (`ID1`)
  ) ENGINE=MyISAM DEFAULT charSET=latin1
  select count(*) from r2;
  ......

MySQL行锁深入研究

来源:http://blog.csdn.net/ldb2741/archive/2010/02/25/5325161.aspx
做项目时由于业务逻辑的需要,必须对数据表的一行或多行加入行锁,举个最简单的例子,图书借阅系统。假设 id=1 的这本书库存为 1 ,但是有 2 个人同时来借这本书,此处的逻辑为
view plaincopy to clipboardprint?
Select   restnum&nbs ......

注意Mysql数据截断

Beware of MySQL Data Truncation
http://www.mysqlperformanceblog.com/2009/02/07/beware-of-mysql-data-truncation/
比如:有一个表aritcle和另一个表article_comment,关联是article的id
CREATE TABLE `article` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(200) NOT NULL,
......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号