centos6.5安装mysql5.6.17
http://www.cnblogs.com/kudosharry/articles/3723453.html
http://blog.csdn.net/wendi_0506/article/details/39478369
#安装依赖包yum -y install make gcc-c++ cmake bison-devel ncurses-devel #(不然yum不支持使用zlib*里的*号)yum update yum -y install gcc gcc-c++ gcc-g77 autoconf automake zlib* fiex* libxml* ncurses-devel libmcrypt* libtool-ltdl-devel* make cmake #下载源码wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.17.tar.gz#添加mysql用户 groupadd mysql useradd -g mysql mysql #解压tar zxvf mysql-5.6.17.tar.gz cd mysql-5.6.17#编译 cmake \-DCMAKE_INSTALl_PREFIX=/usr/local/mysql \-DMYSQL_DATADIR=/usr/local/mysql/data \-DSYSCONFDIR=/usr/local/mysql/etc \-DWITH_MYISAM_STORAGE_ENGINE=1 \-DWITH_INNOBASE_STORAGE_ENGINE=1 \-DWITH_MEMORY_STORAGE_ENGINE=1 \-DWITH_READLINE=1 \-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \-DMYSQL_TCP_PORT=3306 \-DENABLED_LOCAL_INFILE=1 \-DEXTRA_CHARSETS=all \-DDEFAULT_CHARSET=utf8 \-DDEFAULT_COLLATION=utf8_general_ci \-DENABLE_DOWNLOADS=1#发现报错信息 #Warning: Bison executable not found in PATH #CMake Error: Problem with tar_extract_all(): Invalid argument CMake Error: Problem with tar_extract_all(): Invalid argument CMake Error: Problem extracting tar: /soft/mysql-5.6.17/source_downloads/gmock-1.6.0.zip报错的大概原因是tar解包gmock-1.6.0.zip出错了。 cmake的时候,怎么能用tar去解包zip压缩包呢?!gmock-1.6.0.zip是google的c++mock框架,从mysql 5.6开始支持。 cmake参数中设置了DENABLE_DOWNLOADS=1且服务器能连接Internet的话,就会自动下载。 上面报错信息可知,cmake时gmock-1.6.0.zip自动下载到了/soft/mysql-5.6.17/source_downloads/目录下。 #解决办法yum -y install bison unzip#手动编译安装gmock,然后再cmake: cd /soft/mysql-5.6.17/source_downloads/unzip gmock-1.6.0.zipcd gmock-1.6.0./configuremake#当然,个人觉得这个报错关系不大,可忽略之。 #尤其是MySQL服务器在内网无法联接到互联网网的情况,是无法下载gmock-1.6.0.zip,也不会报错上面的CMake Error报错 #解决完毕 #重新编译mysql后发现没有问题 #编译参数可以参考http://dev.mysql.com/doc/refman/5.5/en/source-configuration-options.html#安装makemake install#到此mysql安装完毕 #修改/usr/local/mysql权限chown -R mysql:mysql /usr/local/mysql #进入安装路径 cd /usr/local/mysql #初始化mysql数据库 scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/3306/data --user=mysql WARNING: Default config file /etc/my.cnf exists on the system This file will be read by default by the MySQL server If you do not want to use this, either remove it, or use the--defaults-file argument to mysqld_safe when starting the server 注:在启动MySQL服务时,会按照一定次序搜索my.cnf,先在/etc目录下找,找不到则会搜索"$basedir/my.cnf",在本例中就是 /usr/local/mysql/my.cnf,这是新版MySQL的配置文件的默认位置!注意:在CentOS 6.4版操作系统的最小安装完成后,在/etc目录下会存在一个my.cnf,需要将此文件更名为其他的名字,如:/etc/my.cnf.bak,否则,该文件会干扰源码安装的MySQL的正确配置,造成无法启动。 或者使用--defaults-file参数指定配置文件 #添加服务,拷贝服务脚本到init.d目录,并设置开机启动cp support-files/mysql.server /etc/init.d/mysql chkconfig mysql onmkdir -p /usr/local/mysql/3306/binlog/mkdir -p /usr/local/mysql/3306/relaylog/chown -R mysql:mysql /usr/local/mysql/3306#编辑/usr/local/mysql/my.cnfvi /usr/local/mysql/my.cnf #输入 [client] character-set-server = utf8 port = 3306socket = /tmp/mysql.sock [mysqld] character-set-server = utf8 replicate-ignore-db = mysql replicate-ignore-db = test replicate-ignore-db = information_schema user = mysql port = 3306socket = /tmp/mysql.sock basedir = /usr/local/mysql datadir = /usr/local/mysql/data log-error = /usr/local/mysql/3306/mysql_error.log pid-file = /usr/local/mysql/3306/mysql.pid open_files_limit = 10240back_log = 600max_connections = 5000max_connect_errors = 6000#table_cache = 614external-locking = FALSE max_allowed_packet = 32M sort_buffer_size = 1M join_buffer_size = 1M thread_cache_size = 300#thread_concurrency = 8query_cache_size = 512M query_cache_limit = 2M query_cache_min_res_unit = 2k default-storage-engine = MyISAM thread_stack = 192K transaction_isolation = READ-COMMITTED tmp_table_size = 246M max_heap_table_size = 246M long_query_time = 3log-slave-updates log-bin = /usr/local/mysql/3306/binlog/binlog binlog_cache_size = 4M binlog_format = MIXED max_binlog_cache_size = 8M max_binlog_size = 1G relay-log-index =/usr/local/mysql/3306/relaylog/relaylog relay-log-info-file = /usr/local/mysql/3306/relaylog/relaylog relay-log = /usr/local/mysql/3306/relaylog/relaylog expire_logs_days = 30key_buffer_size = 256M read_buffer_size = 1M read_rnd_buffer_size = 16M bulk_insert_buffer_size = 64M myisam_sort_buffer_size = 128M myisam_max_sort_file_size = 10G myisam_repair_threads = 1myisam_recover interactive_timeout = 120wait_timeout = 120skip-name-resolve #master-connect-retry = 10slave-skip-errors = 1032,1062,126,1114,1146,1048,1396#master-host = 192.168.1.2#master-user = username #master-password = password #master-port = 3306server-id = 1innodb_additional_mem_pool_size = 16M innodb_buffer_pool_size = 512M innodb_data_file_path = ibdata1:12M:autoextend innodb_file_io_threads = 4innodb_thread_concurrency = 8innodb_flush_log_at_trx_commit = 2innodb_log_buffer_size = 16M innodb_log_file_size = 128M innodb_log_files_in_group = 3innodb_max_dirty_pages_pct = 90innodb_lock_wait_timeout = 120innodb_file_per_table = 0#log-slow-queries = /usr/local/mysql/3306/slow.log #long_query_time = 10sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES [mysqldump] quick max_allowed_packet = 32M #启动mysql service mysql start #发现报错,查看错误日志 [ERROR] InnoDB: auto-extending data file ./ibdata1 is of a different size 768 pages (rounded down to MB) than specified in the .cnf file: initial 16384 pages, max 0 (relevant if non-zero) pages!因为没有修改数据文件的配置,这里发现数据文件大小校验失败了。 从这里看见,需要恢复的数据文件有3200页,通过查询mysql文档innodb也结构,可以知道现在mysql innodb每个页的大小是固定的,均为16k,这里的3200页,折算下:768 * 16 / 1024 = 12M 因此,修改mysql的my.cnf为: innodb_data_file_path = ibdata1:12M:autoextend #又发现错误[ERROR] /usr/local/mysql/bin/mysqld: unknown variable 'table_cache=614'原来已经没有这个参数了,注释这行 到此mysql终于启动了~!
这里总结要学会通过错误日志分析结果,动态计算mysql的innerdb的文件大小,即使更新配置文件。
=/usr/local/mysql//etc/-u root -p -S /tmp/*.* TO @ IDENTIFIED BY *.* TO @ IDENTIFIED BY *.* TO @ IDENTIFIED BY
#添加防火墙规则运行远程访问 iptables -A INPUT -p tcp -m state --state NEW -m tcp --dport 3306 -
注意:
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
-A RH-Firewall-1-INPUT -j REJECT --reject-with icmp-host-prohibited
-A RH-Firewall-1-INPUT -j REJECT --reject-with icmp-host-prohibited
是拒绝icmp访问,对于其它的报文返回一个主机禁止访问的错误
开通3306 端