准备好mysql 源码文件
,点击可以下载firebird@locahost~$ sudo apt-get install build-essential libncurses5-dev cmake
firebird@locahost~$ cd /usr/local/src/
firebird@locahost:/usr/local/src$ sudo tar -zxvf mysql-5.6.27.tar.gz
firebird@locahost:/usr/local/src$ cd mysql-5.6.27
firebird@locahost:/usr/local/src/mysql-5.6.27$ sudo mkdir my-build
firebird@locahost:/usr/local/src/mysql-5.6.27$ cd my-build
使用cmake生成安装文件,在这里你可能需要配置一些参数
firebird@locahost:/usr/local/src/mysql-5.6.27/my-build$ sudo cmake ../
firebird@locahost:/usr/local/src/mysql-5.6.27/my-build$ sudo make install
firebird@locahost:/usr/local/src/mysql-5.6.27/my-build$ groupadd mysql
firebird@locahost:/usr/local/src/mysql-5.6.27/my-build$ useradd -g mysql mysql //可能会出现错误一
firebird@locahost:/usr/local/src/mysql-5.6.27/my-build$ cd /usr/local/mysql
firebird@locahost:/usr/local/mysql$ sudo chown -R mysql .
firebird@locahost:/usr/local/mysql$ sudo chgrp -R mysql .
firebird@locahost:/usr/local/mysql$ sudo /usr/local/mysql/scripts/mysql_install_db --user=mysql
firebird@locahost:/usr/local/mysql$ sudo chown -R root .
firebird@locahost:/usr/local/mysql$ sudo chown -R mysql data
firebird@locahost:/usr/local/mysql$ cd /usr/local/src/mysql-5.6.27/my-build
firebird@locahost:/usr/local/src/mysql-5.6.27/my-build$ sudo cp support-files/mysql.server /etc/init.d/mysql
firebird@locahost:/usr/local/src/mysql-5.6.27/my-build$ sudo cp support-files/mysql.server /etc/init.d/mysql
firebird@locahost:/usr/local/src/mysql-5.6.27/my-build$ sudo update-rc.d mysql defaults
firebird@locahost:/usr/local/mysql$ chown -R mysql:mysql /usr/local/mysql
firebird@locahost:/usr/local/mysql$ sudo chmod 755 /etc/init.d/mysql //设置文本的权限,然后可以使用service启动了
firebird@locahost:/usr/local/mysql$ chmod 777 /usr/local/mysql/* //设置用户mysql目录最大权限
firebird@locahost:/usr/local/mysql$ chmod 644 /usr/local/mysql/my.cnf //设置用户不可写权限
firebird@locahost:/usr/local/src/mysql-5.6.27/my-build$ sudo /etc/init.d/mysql start //启动方式一,和service启动一样
firebird@locahost:/usr/local/mysql$ bin/mysqld_safe --user=mysql & //启动方式二
下面是my.cnf的配置文件:
# For advice on how to change settings please see # http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html [client] port= 3306 socket= /var/run/mysqld/mysqld.sock # Here is entries for some specific programs # The following values assume you have at least 32M ram # This was formally known as [safe_mysqld]. Both versions are currently parsed. [mysqld_safe] socket= /var/run/mysqld/mysqld.sock nice= 0 [mysqld] # # * Basic Settings # user= mysql pid-file= /var/run/mysqld/mysqld.pid socket= /var/run/mysqld/mysqld.sock basedir= /usr/local/mysql datadir= /usr/local/mysql/data port= 3306 tmpdir= /tmp lc-messages-dir= /usr/local/mysql/share skip-external-locking # # Instead of skip-networking the default is now to listen only on # localhost which is more compatible and is not less secure. bind-address= 0.0.0.0 # # * Fine Tuning # #innodb_buffer_pool_size 这是你安装完InnoDB后第一个应该设置的选项。缓冲池是数据和索引缓存的地方:这个值越大越好,这能保证你在大多数的读取操作时使用的是内存而不是硬盘。典型的值是5-6GB(8GB内存),20-25GB(32GB内存),100-120GB(128GB内存)。 innodb_buffer_pool_size = 6G #这是redo日志的大小。redo日志被用于确保写操作快速而可靠并且在崩溃时恢复。如果你知道你的应用程序需要频繁的写入数据并且你使用的时MySQL 5.6,你可以一开始就把它这是成4G。 innodb_log_file_size = 4G key_buffer= 16M max_allowed_packet= 100M thread_stack= 192K thread_cache_size = 8 # This replaces the startup script and checks MyISAM tables if needed # the first time they are touched myisam-recover = BACKUP max_connections = 6000 #table_cache = 64 #thread_concurrency = 10 # # * Query Cache Configuration # query_cache_limit= 1M #query_cache_size:query cache(查询缓存)是一个众所周知的瓶颈,甚至在并发并不多的时候也是如此。 最佳选项是将其从一开始就停用,设置query_cache_size = 0(现在MySQL 5.6的默认值) query_cache_size = 0 # # * Logging and Replication # # Both location gets rotated by the cronjob. # Be aware that this log type is a performance killer. # As of 5.1 you can enable the log at runtime! #general_log_file = /var/log/mysql/mysql.log #general_log = 1 # # Error log - should be very few entries. # log_error = /usr/local/mysql/log/error.log # # Here you can see queries with especially long duration #log_slow_queries= /var/log/mysql/mysql-slow.log #long_query_time = 2 #log-queries-not-using-indexes # # The following can be used as easy to replay backup logs or for replication. # note: if you are setting up a replication slave, see README.Debian about # other settings you may need to change. log-bin=mysql-bin server-id=186 binlog_format=Mixed #log_bin= /var/log/mysql/mysql-bin.log expire_logs_days= 10 max_binlog_size = 100M #InnoDB配置 #innodb_file_per_table这项设置告知InnoDB是否需要将所有表的数据和索引存放在共享表空间里(innodb_file_per_table = OFF) 或者为每张表的数据单独放在一个.ibd文件(innodb_file_per_table = ON) innodb_file_per_table=1 #打开文件个数限制,1.物理备份mysql用 open_files_limit = 10480 # 所有线程所打开表的数量. # 增加此值就增加了 mysqld 所需要的文件描述符的数量 # 这样你需要确认在 [mysqld_safe] 中 “open-files-limit” 变量设置打开文件数量允许至少等于 table_cache 的值 table_open_cache = 4096 # innodb_open_files = 1000 [mysqldump] quick quote-names max_allowed_packet= 16M [mysql] #no-auto-rehash# faster start of mysql but no tab completition [isamchk] key_buffer= 16M sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES