【技術分享】【mysql】ubuntu14.04下 mysql5.6源碼安裝

前提

   準備好mysql 源碼文件 mysql-5.6.27.tar.gz,點擊可以下載

安裝

1: 下載安裝編譯MySQL源碼需要的庫

firebird@locahost~$   sudo apt-get install build-essential libncurses5-dev cmake

2: 把文件 上傳到 /usr/local/src 目錄下,解壓MySQL源碼包

firebird@locahost~$   cd /usr/local/src/

firebird@locahost:/usr/local/src$   sudo tar -zxvf mysql-5.6.27.tar.gz

3: 使用cmake生成安裝文件

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 ../

4: 安裝MySQL

firebird@locahost:/usr/local/src/mysql-5.6.27/my-build$   sudo make install

5: 將MySQL添加爲開機啓動的服務

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

覆蓋修改my.cnf文件。

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 //設置用戶不可寫權限

6: 啓動MySQL服務器,以下兩種啓動方式均可

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


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章