Mysql 之 編譯安裝方法(Mysql5.7)
阿新 • • 發佈:2018-08-23
select eas base sql_mod work names ase 下載安裝 eating 參考本博客文章:
http://blog.51cto.com/12965094/2129267
http://blog.51cto.com/12965094/2129267
1. 下載安裝包 wget http://downloads.sourceforge.net/project/boost/boost/1.59.0/boost_1_59_0.tar.gz wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.21.tar.gz 2.安裝依賴包 yum -y install gcc gcc-c++ ncurses ncurses-devel cmake 3.添加mysql 用戶與組 groupadd mysql useradd -r -g mysql mysql 4.新建MYSQL的安裝目錄,與數據存放目錄 mkdir -p /app/mysql mkdir -p /app/data 5.解壓安裝 tar -zxvf boost_1_59_0.tar.gz tar -zxvf mysql-5.7.21.tar.gz cd mysql-5.7.21 #進入mysql的解壓目錄 6.使用cmake 編譯mysql cmake . -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=1 7.編譯安裝mysql make && make install 8.設置開機自動啟動腳本 cp /app/mysql/support-files/mysql.server /etc/init.d/mysqld chmod +x /etc/init.d/mysqld chkconfig --add mysqld chkconfig mysqld on 9.修改MYSQL的環境變量 vi /etc/profile export PATH=$PATH:/app/mysql/bin source /etc/profile 10.修改MYSQL所在目錄權限 chown -R mysql:mysql /app/mysql 11.初始化MYSQL數據庫 [root@localhost ~]# /app/mysql/bin/mysqld --initialize-insecure --user=mysql --basedir=/app/mysql --datadir=/app/mysql/data 2018-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=45790 2018-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] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option. [root@localhost ~]# 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_logfile1 drwxr-x---. 2 mysql mysql 4096 Mar 26 15:31 mysql drwxr-x---. 2 mysql mysql 4096 Mar 26 15:31 performance_schema drwxr-x---. 2 mysql mysql 12288 Mar 26 15:31 sys 12.修改配置文件,如下: vi /etc/my.cnf [client] port=3306 socket=/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 = mysql basedir = /app/mysql datadir = /app/mysql/data port=3306 server-id = 1 socket=/tmp/mysql.sock character-set-server = utf8 #log-error = /var/log/mysql/error.log #pid-file = /var/log/mysql/mysql.pid general_log = 1 skip-name-resolve #skip-networking back_log = 300 max_connections = 1000 max_connect_errors = 6000 open_files_limit = 65535 table_open_cache = 128 max_allowed_packet = 4M binlog_cache_size = 1M max_heap_table_size = 8M tmp_table_size = 16M read_buffer_size = 2M read_rnd_buffer_size = 8M sort_buffer_size = 8M join_buffer_size = 28M key_buffer_size = 4M thread_cache_size = 8 query_cache_type = 1 query_cache_size = 8M query_cache_limit = 2M ft_min_word_len = 4 log_bin = mysql-bin binlog_format = mixed expire_logs_days = 30 performance_schema = 0 explicit_defaults_for_timestamp #lower_case_table_names = 1 myisam_sort_buffer_size = 8M myisam_repair_threads = 1 interactive_timeout = 28800 wait_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 risks symbolic-links=0 # Recommended in standard MySQL setup sql_mode=NO_ENGINE_SUBSTITUTION,NO_AUTO_CREATE_USER,STRICT_TRANS_TABLES [mysqldump] quick max_allowed_packet = 16M 13.創建錯誤日誌與PID存放位置 mkdir -p /var/log/mysql/ chown -R mysql:mysql /var/log/mysql/ 14.啟動mysql [root@localhost mysql]# service mysqld start Starting MySQL.[ OK ] [root@localhost mysql]# netstat -tlnp | grep 3306 tcp 0 0 :::3306 :::* LISTEN 27565/mysqld
Mysql 之 編譯安裝方法(Mysql5.7)