1.  需要的组建如下,使用yum方式安装:yum install gcc gcc-c++ kernel-devel ncurses-devel bison cmake

2.下载mysql:http://dev.mysql.com/downloads/mysql/#downloads,选择源码包

3.解压进入mysl文件夹

4. cmake .

5. make && make install

可能回出现下面问题:

-- Could NOT find Curses (missing:  CURSES_LIBRARY CURSES_INCLUDE_PATH)

CMake Error at cmake/readline.cmake:83 (MESSAGE):

  Curses library not found.  Please install appropriate package,

 remove CMakeCache.txt and rerun cmake.On Debian/Ubuntu, package name is libncurses5-dev, on Redhat and derivates it is ncurses-devel.

Call Stack (most recent call first):

  cmake/readline.cmake:136 (FIND_CURSES)

  cmake/readline.cmake:226 (MYSQL_USE_BUNDLED_LIBEDIT)

  CMakeLists.txt:262 (MYSQL_CHECK_READLINE)

按照上面内容提示的方法进行修改:

若是redhat 安装ncurses-devel这个包即可。


[root@localhost mysql-5.6.4-m7]# yum install ncurses-devel*   

[root@localhost mysql-5.6.4-m7]# rm CMakeCache.txt   (注意这里是删除CMakeCache.txt  ,有一个跟他很相似的文件,别删错了!)


6. 添加用户和用户组

groupadd mysql #添加mysql用户组  
useradd -g mysql mysql #创建mysql用户并把它放到mysql组下  
chown -R root:mysql /usr/local/mysql #修改mysql文件属性 

7.

初始化数据目录

#把用到的工具添加到/usr/bin目录  
ln -s /usr/local/mysql/bin/mysqld_multi /usr/bin/mysqld_multi  
ln -s /usr/local/mysql/bin/mysql_install_db /usr/bin/mysql_install_db 

8.

mkdir /usr/local/mysqldata

mkdir /usr/local/mysqldata/mysql3306

mkdir /usr/local/mysqldata/mysql3307

mkdir /usr/local/mysqldata/mysql3308

mkdir /usr/local/mysqldata/mysql3309

#修改属性
chown -R mysql /usr/local/mysqldata/mysql3306

chown -R mysql /usr/local/mysqldata/mysql3307

chown -R mysql /usr/local/mysqldata/mysql3308

chown -R mysql /usr/local/mysqldata/mysql3309

#初始化四个数据目录

cd /usr/local/mysql
scripts/mysql_install_db --datadir=/usr/local/mysqldata/mysql3306 --user=mysql
scripts/mysql_install_db --datadir=/usr/local/mysqldata/mysql3307 --user=mysql
scripts/mysql_install_db --datadir=/usr/local/mysqldata/mysql3308 --user=mysql
scripts/mysql_install_db --datadir=/usr/local/mysqldata/mysql3309 --user=mysql

9.

配置多实例启动脚本 从MySQL的源码中把复制到/etc/init.d/目录下

cp /usr/local/mysql/support-files/mysqld_multi.server /etc/init.d/mysqld_multi.server

10.添加mysql/bin到path中,例如添加到 .bash_profile

ru - root

ls -lf

vi  .bash_profile

添加

export mysqlhome=/usr/local/mysql
PATH=$PATH:$HOME/bin:$mysqlhome/bin

保存

11 修改/etc/my.cnf文件(my.cnf 文件权限:chmod 644 /etc/my.cnf)链接:http://hi.baidu.com/perfect_song/item/32c25c0434dea110ebfe38bb

my.cnf


[plain] view plaincopy

  1. # Example MySQL config file for medium systems.  

  2. #  

  3. # This is for a system with little memory (32M - 64M) where MySQL plays  

  4. # an important part, or systems up to 128M where MySQL is used together with  

  5. # other programs (such as a web server)  

  6. #  

  7. # MySQL programs look for option files in a set of  

  8. # locations which depend on the deployment platform.  

  9. # You can copy this option file to one of those  

  10. # locations. For information about these locations, see:  

  11. # http://dev.mysql.com/doc/mysql/en/option-files.html  

  12. #  

  13. # In this file, you can use all long options that a program supports.  

  14. # If you want to know which options a program supports, run the program  

  15. # with the "--help" option.  

  16.   

  17. # The following options will be passed to all MySQL clients  

  18. [client]  

  19. password    =123456  

  20. #port       =3306  

  21. #socket     =/tmp/mysql.sock1  

  22.   

  23. # Here follows entries for some specific programs  

  24.   

  25. # The MySQL server  

  26. [mysqld1]  

  27. server-id=1  

  28. port        = 3306  

  29. socket      = /tmp/mysql3306.sock  

  30.   

  31. pid-file   = /usr/local/mysqldata/mysql3306/mysql3306.pid  

  32. datadir    = /usr/local/mysqldata/mysql3306  

  33. user=mysql  

  34.   

  35. plugin-load=AUDIT=libaudit_plugin.so  

  36.   

  37. log-bin=mysql-bin1  

  38. binlog-ignore-db=mysql  

  39. replicate-ignore-db=mysql  

  40. log-slave-updates  

  41. slave-skip-errors=all  

  42. sync-binlog=1  

  43. auto-increment-increment=2  

  44. auto-increment-offset=1  

  45.   

  46. character-set-server=utf8  

  47. binlog_format=mixed  

  48. skip-external-locking  

  49. key_buffer_size = 16M  

  50. max_allowed_packet = 1M  

  51. table_open_cache = 64  

  52. sort_buffer_size = 512K  

  53. net_buffer_length = 8K  

  54. read_buffer_size = 256K  

  55. read_rnd_buffer_size = 512K  

  56.   

  57. [mysqld2]  

  58. server-id=2  

  59. port        = 3307  

  60. socket      = /tmp/mysql3307.sock  

  61.   

  62. pid-file   = /usr/local/mysqldata/mysql3307/mysql3307.pid  

  63. datadir    = /usr/local/mysqldata/mysql3307  

  64. user=mysql  

  65.   

  66. log-bin=mysql-bin2  

  67. binlog-ignore-db=mysql  

  68. replicate-ignore-db=mysql  

  69. log-slave-updates  

  70. slave-skip-errors=all  

  71. sync-binlog=1  

  72. auto-increment-increment=2  

  73. auto-increment-offset=2  

  74.   

  75. character-set-server=utf8  

  76. binlog_format=mixed  

  77. skip-external-locking  

  78. key_buffer_size = 16M  

  79. max_allowed_packet = 1M  

  80. table_open_cache = 64  

  81. sort_buffer_size = 512K  

  82. net_buffer_length = 8K  

  83. read_buffer_size = 256K  

  84. read_rnd_buffer_size = 512K  

  85. myisam_sort_buffer_size = 8M  

  86.   

  87. [mysqld3]  

  88. server-id=3  

  89. port        = 3308  

  90. socket      = /tmp/mysql3308.sock  

  91.   

  92. pid-file   = /usr/local/mysqldata/mysql3308/mysql3308.pid  

  93. datadir    = /usr/local/mysqldata/mysql3308  

  94. user=mysql  

  95.   

  96. log-bin=mysql-bin  

  97. binlog-ignore-db=mysql  

  98. replicate-ignore-db=mysql  

  99. log-slave-updates  

  100. slave-skip-errors=all  

  101. sync-binlog=1  

  102. auto-increment-increment=2  

  103. auto-increment-offset=1  

  104.   

  105. character-set-server=utf8  

  106. binlog_format=mixed  

  107. skip-external-locking  

  108. key_buffer_size = 16M  

  109. max_allowed_packet = 1M  

  110. table_open_cache = 64  

  111. sort_buffer_size = 512K  

  112. net_buffer_length = 8K  

  113. read_buffer_size = 256K  

  114. read_rnd_buffer_size = 512K  

  115. myisam_sort_buffer_size = 8M  

  116.   

  117. [mysqld4]  

  118. server-id=4  

  119. port        = 3309  

  120. socket      = /tmp/mysql3309.sock  

  121.   

  122. pid-file   = /usr/local/mysqldata/mysql3309/mysql3309.pid  

  123. datadir    = /usr/local/mysqldata/mysql3309  

  124. user=mysql  

  125.   

  126. log-bin=mysql-bin  

  127. binlog-ignore-db=mysql  

  128. replicate-ignore-db=mysql  

  129. log-slave-updates  

  130. slave-skip-errors=all  

  131. sync-binlog=1  

  132. auto-increment-increment=2  

  133. auto-increment-offset=2  

  134.   

  135. character-set-server=utf8  

  136. binlog_format=mixed  

  137. skip-external-locking  

  138. key_buffer_size = 16M  

  139. max_allowed_packet = 1M  

  140. table_open_cache = 64  

  141. sort_buffer_size = 512K  

  142. net_buffer_length = 8K  

  143. read_buffer_size = 256K  

  144. read_rnd_buffer_size = 512K  

  145. myisam_sort_buffer_size = 8M  

  146.   

  147. # Don't listen on a TCP/IP port at all. This can be a security enhancement,  

  148. # if all processes that need to connect to mysqld run on the same host.  

  149. # All interaction with mysqld must be made via Unix sockets or named pipes.  

  150. # Note that using this option without enabling named pipes on Windows  

  151. # (via the "enable-named-pipe" option) will render mysqld useless!  

  152. #   

  153. #skip-networking  

  154.   

  155. # Replication Master Server (default)  

  156. # binary logging is required for replication  

  157. #log-bin=mysql-bin  

  158.   

  159. # binary logging format - mixed recommended  

  160. #binlog_format=mixed  

  161.   

  162. # required unique id between 1 and 2^32 - 1  

  163. # defaults to 1 if master-host is not set  

  164. # but will not function as a master if omitted  

  165. #server-id  = 1  

  166.   

  167. # Replication Slave (comment out master section to use this)  

  168. #  

  169. # To configure this host as a replication slave, you can choose between  

  170. # two methods :  

  171. #  

  172. # 1) Use the CHANGE MASTER TO command (fully described in our manual) -  

  173. #    the syntax is:  

  174. #  

  175. #    CHANGE MASTER TO MASTER_HOST=<host>, MASTER_PORT=<port>,  

  176. #    MASTER_USER=<user>, MASTER_PASSWORD=<password> ;  

  177. #  

  178. #    where you replace <host>, <user>, <password> by quoted strings and  

  179. #    <port> by the master's port number (3306 by default).  

  180. #  

  181. #    Example:  

  182. #  

  183. #    CHANGE MASTER TO MASTER_HOST='125.564.12.1', MASTER_PORT=3306,  

  184. #    MASTER_USER='joe', MASTER_PASSWORD='secret';  

  185. #  

  186. # OR  

  187. #  

  188. # 2) Set the variables below. However, in case you choose this method, then  

  189. #    start replication for the first time (even unsuccessfully, for example  

  190. #    if you mistyped the password in master-password and the slave fails to  

  191. #    connect), the slave will create a master.info file, and any later  

  192. #    change in this file to the variables' values below will be ignored and  

  193. #    overridden by the content of the master.info file, unless you shutdown  

  194. #    the slave server, delete master.info and restart the slaver server.  

  195. #    For that reason, you may want to leave the lines below untouched  

  196. #    (commented) and instead use CHANGE MASTER TO (see above)  

  197. #  

  198. # required unique id between 2 and 2^32 - 1  

  199. # (and different from the master)  

  200. # defaults to 2 if master-host is set  

  201. # but will not function as a slave if omitted  

  202. #server-id       = 2  

  203. #  

  204. # The replication master for this slave - required  

  205. #master-host     =   <hostname>  

  206. #  

  207. # The username the slave will use for authentication when connecting  

  208. # to the master - required  

  209. #master-user     =   <username>  

  210. #  

  211. # The password the slave will authenticate with when connecting to  

  212. # the master - required  

  213. #master-password =   <password>  

  214. #  

  215. # The port the master is listening on.  

  216. # optional - defaults to 3306  

  217. #master-port     =  <port>  

  218. #  

  219. # binary logging - not required for slaves, but recommended  

  220. #log-bin=mysql-bin  

  221.   

  222. # Uncomment the following if you are using InnoDB tables  

  223. #innodb_data_home_dir = /usr/local/mysql/data  

  224. #innodb_data_file_path = ibdata1:10M:autoextend  

  225. #innodb_log_group_home_dir = /usr/local/mysql/data  

  226. # You can set .._buffer_pool_size up to 50 - 80 %  

  227. # of RAM but beware of setting memory usage too high  

  228. #innodb_buffer_pool_size = 16M  

  229. #innodb_additional_mem_pool_size = 2M  

  230. # Set .._log_file_size to 25 % of buffer pool size  

  231. #innodb_log_file_size = 5M  

  232. #innodb_log_buffer_size = 8M  

  233. #innodb_flush_log_at_trx_commit = 1  

  234. #innodb_lock_wait_timeout = 50  

  235. #basedir = /usr/local/mysql  

  236.   

  237. [mysqldump]  

  238. quick  

  239. max_allowed_packet = 16M  

  240.   

  241. [mysql]  

  242. no-auto-rehash  

  243. # Remove the next comment character if you are not familiar with SQL  

  244. #safe-updates  

  245.   

  246. [myisamchk]  

  247. key_buffer_size = 20M  

  248. sort_buffer_size = 20M  

  249. read_buffer = 2M  

  250. write_buffer = 2M  

  251.   

  252. [mysqlhotcopy]  

  253. interactive-timeout  



其他几篇日志记录多有摘抄,比较乱:

记录mysql主主备份实现方法: http://blog.csdn.net/mr__fang/article/details/8692523

linux下mysql多实例安装,并实现主主同步:http://blog.csdn.net/mr__fang/article/details/8692091

mysql-5.6.4-m7 install in linux:http://blog.csdn.net/mr__fang/article/details/8874439

Linux下安装MySQL: http://blog.csdn.net/mr__fang/article/details/8874411

mysql实现主主同步(转载1):http://blog.csdn.net/mr__fang/article/details/8692422

mysql实现主主同步(转载2):http://blog.csdn.net/mr__fang/article/details/8692480