Mysql 之 編譯安裝方法(Mysql5.7)

來源:互聯網
上載者:User

標籤:my.cnf   pass   join   mbed   query   ges   mkdir   tst   values   

參考本部落格文章:
http://blog.51cto.com/12965094/2129267

1. 下載安裝包wget http://downloads.sourceforge.net/project/boost/boost/1.59.0/boost_1_59_0.tar.gzwget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.21.tar.gz2.安裝依賴包yum -y install gcc gcc-c++ ncurses ncurses-devel cmake3.添加mysql 使用者與組groupadd mysql useradd -r -g mysql mysql4.建立MYSQL的安裝目錄,與資料存放目錄mkdir -p /app/mysqlmkdir -p /app/data5.解壓安裝tar -zxvf boost_1_59_0.tar.gztar -zxvf mysql-5.7.21.tar.gzcd mysql-5.7.21      #進入mysql的解壓目錄6.使用cmake 編譯mysqlcmake . -DCMAKE_INSTALL_PREFIX=/app/mysql -DMYSQL_DATADIR=/app/data -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/root/boost_1_59_0 -DSYSCONFDIR=/etc \-DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DWITH_FEDERATED_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_MYISAM_STORAGE_ENGINE=1 -DENABLED_LOCAL_INFILE=1 -DENABLE_DTRACE=0 -DDEFAULT_CHARSET=utf8mb4 -DDEFAULT_COLLATION=utf8mb4_general_ci -DWITH_EMBEDDED_SERVER=17.編譯安裝mysqlmake && make install8.設定開機自動啟動指令碼cp /app/mysql/support-files/mysql.server /etc/init.d/mysqldchmod +x /etc/init.d/mysqldchkconfig --add mysqldchkconfig mysqld on9.修改MYSQL的環境變數vi /etc/profileexport PATH=$PATH:/app/mysql/bin source /etc/profile10.修改MYSQL所在目錄許可權chown -R mysql:mysql /app/mysql11.初始化MYSQL資料庫[[email protected] ~]# /app/mysql/bin/mysqld --initialize-insecure --user=mysql --basedir=/app/mysql --datadir=/app/mysql/data2018-03-26T07:31:17.298033Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).2018-03-26T07:31:18.332278Z 0 [Warning] InnoDB: New log files created, LSN=457902018-03-26T07:31:18.436844Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.2018-03-26T07:31:18.453099Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: ac7149bc-30c7-11e8-999a-005056804f18.2018-03-26T07:31:18.458082Z 0 [Warning] Gtid table is not ready to be used. Table ‘mysql.gtid_executed‘ cannot be opened.2018-03-26T07:31:18.458468Z 1 [Warning] [email protected] is created with an empty password ! Please consider switching off the --initialize-insecure option.[[email protected] ~]# ll /app/data/total 110620-rw-r-----. 1 mysql mysql       56 Mar 26 15:31 auto.cnf-rw-r-----. 1 mysql mysql      420 Mar 26 15:31 ib_buffer_pool-rw-r-----. 1 mysql mysql 12582912 Mar 26 15:31 ibdata1-rw-r-----. 1 mysql mysql 50331648 Mar 26 15:31 ib_logfile0-rw-r-----. 1 mysql mysql 50331648 Mar 26 15:31 ib_logfile1drwxr-x---. 2 mysql mysql     4096 Mar 26 15:31 mysqldrwxr-x---. 2 mysql mysql     4096 Mar 26 15:31 performance_schemadrwxr-x---. 2 mysql mysql    12288 Mar 26 15:31 sys12.修改設定檔,如下:vi /etc/my.cnf[client]port=3306socket=/tmp/mysql.sock[mysqld]# Remove leading # and set to the amount of RAM for the most important data# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.# innodb_buffer_pool_size = 128M# Remove leading # to turn on a very important data integrity option: logging# changes to the binary log between backups.# log_bin# These are commonly set, remove the # and set as required.user = mysqlbasedir = /app/mysqldatadir = /app/mysql/dataport=3306server-id = 1socket=/tmp/mysql.sockcharacter-set-server = utf8#log-error = /var/log/mysql/error.log#pid-file = /var/log/mysql/mysql.pidgeneral_log = 1skip-name-resolve#skip-networkingback_log = 300max_connections = 1000max_connect_errors = 6000open_files_limit = 65535table_open_cache = 128 max_allowed_packet = 4Mbinlog_cache_size = 1Mmax_heap_table_size = 8Mtmp_table_size = 16Mread_buffer_size = 2Mread_rnd_buffer_size = 8Msort_buffer_size = 8Mjoin_buffer_size = 28Mkey_buffer_size = 4Mthread_cache_size = 8query_cache_type = 1query_cache_size = 8Mquery_cache_limit = 2Mft_min_word_len = 4log_bin = mysql-binbinlog_format = mixedexpire_logs_days = 30performance_schema = 0explicit_defaults_for_timestamp#lower_case_table_names = 1myisam_sort_buffer_size = 8Mmyisam_repair_threads = 1interactive_timeout = 28800wait_timeout = 28800# Remove leading # to set options mainly useful for reporting servers.# The server defaults are faster for transactions and fast SELECTs.# Adjust sizes as needed, experiment to find the optimal values.# join_buffer_size = 128M# sort_buffer_size = 2M# read_rnd_buffer_size = 2M# Disabling symbolic-links is recommended to prevent assorted security riskssymbolic-links=0# Recommended in standard MySQL setupsql_mode=NO_ENGINE_SUBSTITUTION,NO_AUTO_CREATE_USER,STRICT_TRANS_TABLES[mysqldump]quickmax_allowed_packet = 16M13.建立錯誤記錄檔與PID存放位置mkdir -p /var/log/mysql/chown -R mysql:mysql /var/log/mysql/14.啟動mysql[[email protected] mysql]# service mysqld startStarting MySQL.[  OK  ][[email protected] mysql]# netstat -tlnp | grep 3306tcp        0      0 :::3306                     :::*                        LISTEN      27565/mysqld

Mysql 之 編譯安裝方法(Mysql5.7)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.