当前位置:Gxlcms > mysql > mysql-5.6linux安装方法详细记录

mysql-5.6linux安装方法详细记录

时间:2021-07-01 10:21:17 帮助过:22人阅读

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 可能回出现下面问

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

  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. # The following options will be passed to all MySQL clients
  17. [client]
  18. password
  19. =123456
  20. #port
  21. =3306
  22. #socket
  23. =/tmp/mysql.sock1
  24. # Here follows entries for some specific programs
  25. # The MySQL server
  26. [mysqld1]
  27. server-id=1
  28. port
  29. = 3306
  30. socket
  31. = /tmp/mysql3306.sock
  32. pid-file = /usr/local/mysqldata/mysql3306/mysql3306.pid
  33. datadir = /usr/local/mysqldata/mysql3306
  34. user=mysql
  35. plugin-load=AUDIT=libaudit_plugin.so
  36. log-bin=mysql-bin1
  37. binlog-ignore-db=mysql
  38. replicate-ignore-db=mysql
  39. log-slave-updates
  40. slave-skip-errors=all
  41. sync-binlog=1
  42. auto-increment-increment=2
  43. auto-increment-offset=1
  44. character-set-server=utf8
  45. binlog_format=mixed
  46. skip-external-locking
  47. key_buffer_size = 16M
  48. max_allowed_packet = 1M
  49. table_open_cache = 64
  50. sort_buffer_size = 512K
  51. net_buffer_length = 8K
  52. read_buffer_size = 256K
  53. read_rnd_buffer_size = 512K
  54. [mysqld2]
  55. server-id=2
  56. port
  57. = 3307
  58. socket
  59. = /tmp/mysql3307.sock
  60. pid-file = /usr/local/mysqldata/mysql3307/mysql3307.pid
  61. datadir = /usr/local/mysqldata/mysql3307
  62. user=mysql
  63. log-bin=mysql-bin2
  64. binlog-ignore-db=mysql
  65. replicate-ignore-db=mysql
  66. log-slave-updates
  67. slave-skip-errors=all
  68. sync-binlog=1
  69. auto-increment-increment=2
  70. auto-increment-offset=2
  71. character-set-server=utf8
  72. binlog_format=mixed
  73. skip-external-locking
  74. key_buffer_size = 16M
  75. max_allowed_packet = 1M
  76. table_open_cache = 64
  77. sort_buffer_size = 512K
  78. net_buffer_length = 8K
  79. read_buffer_size = 256K
  80. read_rnd_buffer_size = 512K
  81. myisam_sort_buffer_size = 8M
  82. [mysqld3]
  83. server-id=3
  84. port
  85. = 3308
  86. socket
  87. = /tmp/mysql3308.sock
  88. pid-file = /usr/local/mysqldata/mysql3308/mysql3308.pid
  89. datadir = /usr/local/mysqldata/mysql3308
  90. user=mysql
  91. log-bin=mysql-bin
  92. binlog-ignore-db=mysql
  93. replicate-ignore-db=mysql
  94. log-slave-updates
  95. slave-skip-errors=all
  96. sync-binlog=1
  97. auto-increment-increment=2
  98. auto-increment-offset=1
  99. character-set-server=utf8
  100. binlog_format=mixed
  101. skip-external-locking
  102. key_buffer_size = 16M
  103. max_allowed_packet = 1M
  104. table_open_cache = 64
  105. sort_buffer_size = 512K
  106. net_buffer_length = 8K
  107. read_buffer_size = 256K
  108. read_rnd_buffer_size = 512K
  109. myisam_sort_buffer_size = 8M
  110. [mysqld4]
  111. server-id=4
  112. port
  113. = 3309
  114. socket
  115. = /tmp/mysql3309.sock
  116. pid-file = /usr/local/mysqldata/mysql3309/mysql3309.pid
  117. datadir = /usr/local/mysqldata/mysql3309
  118. user=mysql
  119. log-bin=mysql-bin
  120. binlog-ignore-db=mysql
  121. replicate-ignore-db=mysql
  122. log-slave-updates
  123. slave-skip-errors=all
  124. sync-binlog=1
  125. auto-increment-increment=2
  126. auto-increment-offset=2
  127. character-set-server=utf8
  128. binlog_format=mixed
  129. skip-external-locking
  130. key_buffer_size = 16M
  131. max_allowed_packet = 1M
  132. table_open_cache = 64
  133. sort_buffer_size = 512K
  134. net_buffer_length = 8K
  135. read_buffer_size = 256K
  136. read_rnd_buffer_size = 512K
  137. myisam_sort_buffer_size = 8M
  138. # Don't listen on a TCP/IP port at all. This can be a security enhancement,
  139. # if all processes that need to connect to mysqld run on the same host.
  140. # All interaction with mysqld must be made via Unix sockets or named pipes.
  141. # Note that using this option without enabling named pipes on Windows
  142. # (via the "enable-named-pipe" option) will render mysqld useless!
  143. #
  144. #skip-networking
  145. # Replication Master Server (default)
  146. # binary logging is required for replication
  147. #log-bin=mysql-bin
  148. # binary logging format - mixed recommended
  149. #binlog_format=mixed
  150. # required unique id between 1 and 2^32 - 1
  151. # defaults to 1 if master-host is not set
  152. # but will not function as a master if omitted
  153. #server-id
  154. = 1
  155. # Replication Slave (comment out master div to use this)
  156. #
  157. # To configure this host as a replication slave, you can choose between
  158. # two methods :
  159. #
  160. # 1) Use the CHANGE MASTER TO command (fully described in our manual) -
  161. # the syntax is:
  162. #
  163. # CHANGE MASTER TO MASTER_HOST=<host>, MASTER_PORT=<port>,
  164. # MASTER_USER=<user>, MASTER_PASSWORD=<password> ;
  165. #
  166. # where you replace <host>, <user>, <password> by quoted strings and
  167. # <port> by the master's port number (3306 by default).
  168. #
  169. # Example:
  170. #
  171. # CHANGE MASTER TO MASTER_HOST='125.564.12.1', MASTER_PORT=3306,
  172. # MASTER_USER='joe', MASTER_PASSWORD='secret';
  173. #
  174. # OR
  175. #
  176. # 2) Set the variables below. However, in case you choose this method, then
  177. # start replication for the first time (even unsuccessfully, for example
  178. # if you mistyped the password in master-password and the slave fails to
  179. # connect), the slave will create a master.info file, and any later
  180. # change in this file to the variables' values below will be ignored and
  181. # overridden by the content of the master.info file, unless you shutdown
  182. # the slave server, delete master.info and restart the slaver server.
  183. # For that reason, you may want to leave the lines below untouched
  184. # (commented) and instead use CHANGE MASTER TO (see above)
  185. #
  186. # required unique id between 2 and 2^32 - 1
  187. # (and different from the master)
  188. # defaults to 2 if master-host is set
  189. # but will not function as a slave if omitted
  190. #server-id = 2
  191. #
  192. # The replication master for this slave - required
  193. #master-host = <hostname>
  194. #
  195. # The username the slave will use for authentication when connecting
  196. # to the master - required
  197. #master-user = <username>
  198. #
  199. # The password the slave will authenticate with when connecting to
  200. # the master - required
  201. #master-password = <password>
  202. #
  203. # The port the master is listening on.
  204. # optional - defaults to 3306
  205. #master-port = <port>
  206. #
  207. # binary logging - not required for slaves, but recommended
  208. #log-bin=mysql-bin
  209. # Uncomment the following if you are using InnoDB tables
  210. #innodb_data_home_dir = /usr/local/mysql/data
  211. #innodb_data_file_path = ibdata1:10M:autoextend
  212. #innodb_log_group_home_dir = /usr/local/mysql/data
  213. # You can set .._buffer_pool_size up to 50 - 80 %
  214. # of RAM but beware of setting memory usage too high
  215. #innodb_buffer_pool_size = 16M
  216. #innodb_additional_mem_pool_size = 2M
  217. # Set .._log_file_size to 25 % of buffer pool size
  218. #innodb_log_file_size = 5M
  219. #innodb_log_buffer_size = 8M
  220. #innodb_flush_log_at_trx_commit = 1
  221. #innodb_lock_wait_timeout = 50
  222. #basedir = /usr/local/mysql
  223. [mysqldump]
  224. quick
  225. max_allowed_packet = 16M
  226. [mysql]
  227. no-auto-rehash
  228. # Remove the next comment character if you are not familiar with SQL
  229. #safe-updates
  230. [myisamchk]
  231. key_buffer_size = 20M
  232. sort_buffer_size = 20M
  233. read_buffer = 2M
  234. write_buffer = 2M
  235. [mysqlhotcopy]
  236. interactive-timeout
  237. </port></password></username></hostname></port></password></user></host></password></user></port></host>

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

记录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

http://blog.csdn.net/mr__fang/article/details/8692422

http://blog.csdn.net/mr__fang/article/details/8692480


人气教程排行