Feb 22

MySQL replication configuration for Community Edition

    This is just a brief summary for the whole steps, more details please refer to : http://dev.mysql.com/doc/refman/5.5/en/replication.html

Steps: 

1. master and slave server must have the same database structure and same data;(dump data from master to slave).

2. for master server:set server-id=1 and open binary log(log-bin=mysql-bin.log)

    for slave server : set server-id=2.

3. start master server, use "show master status\G" to show binary log file name and position;

4. start slave server, use below command to set slave server's related master server info.

mysql> CHANGE MASTER TO

         ->     MASTER_HOST='master_host_name',

         ->     MASTER_USER='replication_user_name',

         ->     MASTER_PASSWORD='replication_password',

         ->     MASTER_LOG_FILE='recorded_log_file_name',

         ->     MASTER_LOG_POS=recorded_log_position;

5. check the log of master and slave server, if no errors, then means all ready, then execute start slave in slave server.
Reference command :  "show processlist\G" , "show master status\G", "show slave status\G" , "start slave" , "stop slave" , "reset slave" , "show variables like
*** "

Oct 08

一个SQL分页存储过程

CREATE    PROCEDURE [dbo].[U_C_Page]
@TableName varchar(40),   —-查询表名
@ColumnsName nvarchar(200) =’ * ‘, —-查询字段名(column1,column2……)
@PKColumn varchar(20),   —-主键字段
@Condition nvarchar(1000) =’  1=1 ‘, —-查询条件
@OrderType bit =0,   —-排序类型 0:asc 1:desc
@OrderColumn varchar(20),  —-排序字段
@PageSize int =20,   —-查询条数
@CurrentPage int =1   —-当前页 Continue reading

Sep 18

MYSQL5.0中文乱码问题 字符集utf8–dos下插入中文insert,select显示中文

如何使用字符集utf8,在DOS(mysql>)下,能insert中文,select也能看正常的中文?
0. MySQL5.0中文问题解决方案如下:
1.在dos环境下,用mysql –default-character-set=utf8 -u root -p 这句话进入mysql~~
2.mysql> show variables like ‘character\_set\_%’;

character_set_client   utf8
character_set_connection utf8
character_set_database   utf8
character_set_results    utf8
character_set_server   utf8
character_set_system     utf8
mysql> set character_set_results=gbk;
mysql> set character_set_client=gbk;
mysql> show variables like ‘character\_set\_%’;
character_set_client   gbk
character_set_connection utf8
character_set_database   utf8
character_set_results    gbk
character_set_server   utf8
character_set_system     utf8

3.建数据库、表,如下:
mysql>create database demo;
mysql>use demo;
mysql>create table user ( id int(11) not null auto_increment primary key,
name varchar(100) not Null , age int)type=MyISAM,default character set utf8;
insert into user(name,age) values(‘本职工作’,19);
insert into user(name,age) values(‘张工作’,22);
insert into user(name,age) values(‘王作’,29);

搞定,在DOS(mysql>)下,能insert中文,select也能看正常的中文。

Jul 19

MySQL启动1067错误的解决

    昨天晚上在不小心把xp系统给搞坏了,今天早晨起来一狠心就把原来机器上的XP跟vista都歌格了,干脆就直接装vista玩儿算了。结果所有的软件又都得重新装一遍了,装到mysql的时候就开始处问题了,以前也有遇到过并且也解决了,只是没当回事儿,结果这次又遇到了,网上找了半天都不是根本的解决办法,最后还是在mysql自己的配置文件中找到了解决的办法,一开始就隐隐约约的记得mysqld这个命令时有一个参数可以设置配置文件的路径的,可是一直记不起来时哪个参数,后来在无意中看到了,现在总结一下。 Continue reading