源碼安裝mysql-5.6.32.tar.gz

來源:互聯網
上載者:User

標籤:

 

http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.32.tar.gz

安裝依賴包:

#yum install wget bison gcc gcc-c++ wget make cmake ncurses-devel libtool zilib-devel -y

規劃好目錄:

# mkdir -p /data/mysqldata/{3306/{data,tmp,binlog,redo-log,undo-log},backup,scritps}
[[email protected]]# tree /data/servers/data/└── mysqldata    ├── 3306    │   ├── binlog    │   ├── data    │   ├── redo-log    │   ├── tmp    │   └── undo-log    ├── backup    └── scritps9 directories, 0 files

建立mysql使用者,授權

#groupadd mysql#useradd -g mysql mysql
[[email protected] /]# chown mysql:mysql -R /data/mysqldata

產生編譯設定檔:

[[email protected] mysql-5.6.31]# cmake -DCMAKE_INSTALL_PREFIX=/app/servers/mysql-5.6.31 -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DENABLED_LOCAL_INFILE=ON -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_FEDERATED_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_EXAMPLE_STORAGE_ENGINE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DWITH_PERFSCHEMA_STORAGE_ENGINE=1 -DCOMPILATION_COMMENT=‘JSS for mysqltest‘ -DWITH_READLINE=ON -DSYSCONFDIR=/data/mysqldata/3306 -DMYSQL_UNIX_ADDR=/data/mysqldata/3306/mysql.sock

上面的cmake是不能成功,初始化不能成功(下面的代碼沒問題):

cmake -DCMAKE_INSTALL_PREFIX=/app/servers/mysql-5.5.20 -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS:STRING=all -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DMYSQL_USER=mysql -DMYSQL_TCP_PORT=3306

 

 

DCMAKE_INSTALL_PREFIX mysql安裝目錄,這裡指的是mysql軟體的安裝路徑,
DDEFAULT_CHARSET 指定mysql的字元集。
DDEFAULT_COLLATION 指定mysql服務的預設校對規則。
DENABLED_LOCAL_INFILE

是否允許從用戶端本地載入資料到Mysql服務端,專用於load data infile語句,預設不允許

DWITH_*_STORAGE_ENGINE 靜態編譯某種儲存引擎。*表示儲存引擎名稱,1表示開啟。
DCOMPILATION_COMMENT 編譯資訊,後面啟動的時候會看到。
DWITH_READLINE mysql輸入輸出的處理方式
DSYSCONFDIR mysql參數檔案的預設路徑
DMYSQL_UNIX_ADDR 通訊端檔案儲存體路徑位置
[[email protected] mysql-5.6.31]# make && make install
[[email protected] mysql-5.6.31]# chown mysql:mysql -R /app/servers/mysql-5.6.31
[[email protected] mysql-5.6.31]# chown mysql.mysql /data/mysqldata/3306/my.cnf [[email protected] mysql-5.6.31]# ll -h /data/mysqldata/3306/my.cnf-rw-r--r-- 1 mysql mysql 1.6K Aug 17 19:13 /data/mysqldata/3306/my.cnf[[email protected] mysql-5.6.31]# cat /data/mysqldata/3306/my.cnf [client]port = 3306socket = /data/mysqldata/3306/mysql.sock#Mysql Server[mysqld]port = 3306user = mysqlsocket = /data/mysqldata/3306/mysql.sockpid-file = /data/mysqldata/3306/mysql.pidbasedir = /app/servers/mysql-5.6.31datadir = /data/mysqldata/3306/datatmpdir = /data/mysqldata/3306/tmpopen_files_limit = 512explicit_defaults_for_timestampsql_mode = NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES#Buffermax_allowed_packet = 64Mmax_heap_table_size = 64Mnet_buffer_length = 8Ksort_buffer_size = 2Mjoin_buffer_size =4Mread_buffer_size = 2Mread_rnd_buffer_size = 16M#Loglog-bin = /data/mysqldata/3306/binlog/mysql-binbinlog_cache_size = 16mmax_binlog_cache_size = 128mmax_binlog_size = 128mbinlog_format = rowlog_output = FILElog-error = ../mysql-error.logslow_query_log = 1slow_query_log_file = ../slow_query.loggeneral_log = 0general_log_file = ../general_query.logexpire-logs-days = 14#master-slave,這裡先不做任何配置,下一個章節會講到。server-id = 1 binlog-ignore-db = testreplicate-ignore-db = testlog-slave-updates=true#InnoDBinnodb_data_file_path = libdata1:1024M:autoextendinnodb_log_file_size = 32Minnodb_log_files_in_group =6innodb_log_group_home_dir = /data/mysqldata/3306/redo-log/innodb_buffer_pool_size = 200Msync_binlog = 8#Undo Logs這裡被我注釋了,5.6版本undo可以拆分出來,用xtrabackup恢複有異常,就注釋了。#innodb_undo_directory = /data/mysqldata/3306/undo-log/#innodb_undo_log = 64#innodb_undo_tablespaces = 16[mysql]no-auto-rehashprompt=(\\[email protected]\\h) [\\d]>\\_
[[email protected] servers]# lsmfs  mysql-5.6.31[[email protected] servers]# ln -s mysql-5.6.31/ mysql[[email protected] servers]# lltotal 8drwxr-xr-x.  6 root  root  4096 Jun 30 21:31 mfslrwxrwxrwx   1 root  root    13 Aug 17 19:15 mysql -> mysql-5.6.31/drwxr-xr-x  13 mysql mysql 4096 Aug 17 19:01 mysql-5.6.31

http://jiajinh.blog.51cto.com/2085098/1627966

# /app/servers/mysql-5.6.31/scripts/mysql_install_db --datadir=/data/mysqldata/3306/data --basedir=/app/servers/mysql-5.6.31
/app/servers/mysql-5.6.31/my.cnf,/app/servers/mysql-5.6.31/my-new.cnf,/etc/my.cnf,如果這些檔案存在,可以清除掉。就發現warning消失了

啟動資料庫,我這裡採用sale的方式啟動:

[[email protected] servers]# /app/servers/mysql/bin/mysqld_safe --defaults-file=/data/mysqldata/3306/my.cnf &[1] 25381[[email protected] servers]# 160818 21:58:55 mysqld_safe Logging to ‘/data/mysqldata/3306/data/../mysql-error.log‘.160818 21:58:56 mysqld_safe Starting mysqld daemon with databases from /data/mysqldata/3306/data

查看啟動狀態:

[[email protected] log]# ps aux |grep mysqldroot     25381  0.0  0.0 106232  1404 pts/0    S    21:58   0:00 /bin/sh /app/servers/mysql/bin/mysqld_safe --defaults-file=/data/mysqldata/3306/my.cnfmysql    25926  1.0  3.8 1088212 455204 pts/0  Sl   21:58   0:01 /app/servers/mysql-5.6.31/bin/mysqld --defaults-file=/data/mysqldata/3306/my.cnf --basedir=/app/servers/mysql-5.6.31 --datadir=/data/mysqldata/3306/data --plugin-dir=/app/servers/mysql-5.6.31/lib/plugin --user=mysql --log-error=/data/mysqldata/3306/data/../mysql-error.log --open-files-limit=512 --pid-file=/data/mysqldata/3306/mysql.pid --socket=/data/mysqldata/3306/mysql.sock --port=3306root     26061  0.0  0.0 103308   876 pts/10   S+   22:00   0:00 grep mysqld
[[email protected] log]# /app/servers/mysql/bin/mysql Welcome to the MySQL monitor.  Commands end with ; or \g.Your MySQL connection id is 1Server version: 5.6.32-log Source distributionCopyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.([email protected]) [(none)]> 

關閉資料庫:

[[email protected] log]# /app/servers/mysql/bin/mysqladmin -S /data/mysqldata/3306/mysql.sock shutdown
[[email protected] log]# netstat -ano |grep 3306[[email protected] log]# ps -el|grep mysql

為保障安全性,修改root使用者登入資訊

([email protected]) [mysql]> select user,password,host from user;+------+----------+-----------+| user | password | host      |+------+----------+-----------+| root |          | localhost || root |          | ok        || root |          | 127.0.0.1 || root |          | ::1       ||      |          | localhost ||      |          | ok        |+------+----------+-----------+6 rows in set (0.00 sec)

刪除所有賬戶資訊,只保留本地登入:

([email protected]) [mysql]> delete from mysql.user where (user,host) not in (select ‘root‘,‘localhost‘);Query OK, 5 rows affected (0.00 sec)
([email protected]) [mysql]> select user,password,host from user;                  
+------+----------+-----------+| user | password | host |+------+----------+-----------+| root | | localhost |+------+----------+-----------+1 row in set (0.00 sec)

 

源碼安裝mysql-5.6.32.tar.gz

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.