1. Install the development environment
Package Required for installation:
1 |
yum install -y ncurses-devel openssl-devel zlib-devel ncurses-devel openssl gcc gcc-c++
|
2. Installing CMake
12345 |
tar -zvxf cmake- 3.8 . 0 .tar.gz -C /usr/local/src
cd /usr/local/src/cmake- 3.8 . 0 ./bootstrap make make install |
3. Preparation before installation
3.1. Prepare the Catalogue
1 |
mkdir -pv /data/mysql/ 3306 /{data,logs/{binlog,relaylog},run,tmp} |
3.2. Add Users
Groupadd-g 3306 mysqluseradd-u 3306-g 3306-s/sbin/nologin-m MySQL
chown mysql:mysql /data/mysql/
3306
/ -R
4. Compiling the installation
123456789101112131415161718192021222324 |
# tar -xf mariadb-10.1.22.tar.gz -C /usr/local/src
# cd mariadb-10.1.22
# cmake \
-DCMAKE_INSTALL_PREFIX=
/usr/local/mysql
\
-DMYSQL_DATADIR=
/data/mysql/3306/data
\
-DSYSCONFDIR=
/etc
\
-DMYSQL_USER=mysql \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DWITH_SSL=system \
-DWITH_ZLIB=system \
-DWITH_LIBWRAP=0 \
-DMYSQL_UNIX_ADDR=
/tmp/mysql
.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DMYSQL_UNIX_ADDR=
/tmp/mysql
.sock \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DWITH_DEBUG=0 \
-DWITHOUT_MROONGA_STORAGE_ENGINE=1
# make
# make install
-dcmake_install_prefix=/usr/local/mysql \ # Install root directory -dmysql_datadir=/data/mysql/data \ # data Store directory -DTMPDIR=/DATA/MYSQL/TMP \ # temporary file storage directory -dmysql_unix_addr=/data/mysql/run/mysqld.sock \ # UNIX Socket file -DSYSCONFDIR=/ETC \ # configuration file storage Directory -dwith_myisam_storage_engine=1 \ # MYISAM engine support -dwith_innobase_storage_engine=1 \ # InnoDB engine support -dwith_archive_storage_engine=1 \ # ARCHIVE engine support -dwith_blackhole_storage_engine=1 \ # Blackhole engine support -dwith_perfschema_storage_engine=1 \ # Perfschema engine support -dwith_federated_storage_engine=1 \ # Federatedx engine support -dwith_tokudb_storage_engine=1 \ # TOKUDB engine support -dwith_xtradb_storage_engine=1 \ # XTRADB engine support -dwith_aria_storage_engine=1 \ # ARIA engine support -dwith_partition_storage_engine=1 \ # PARTITION engine support -dwith_sphinx_storage_engine=1 \ # SPHINX engine support -dwith_readline=1 \ # READLINE Library -dmysql_tcp_port=3306 \ # TCP/IP Port -denabled_local_infile=1 \ # Enable loading of local data -dwith_extra_charsets=all \ # Extended Support encoding (all | utf8,gbk,gb2312 | none) -dextra_charsets=all \ # Extended character support -DDEFAULT_CHARSET=UTF8 \ # Default Character set -DDEFAULT_COLLATION=UTF8_GENERAL_CI \ # Default character proofing -dcmake_exe_linker_flags= '-ljemalloc ' \ # Jemalloc Memory Management Library -dwith_safemalloc=off \ # Turn off default memory management -dwith_debug=0 \ # Turn off debug mode -denable_profiling=1 \ # Enable profiling feature -dwith_ssl=system \ # using the own SSL library on the system -dwith_zlib=system \ # Using the ZLIB library that comes with the system -dwith_libwrap=0 # Disable LibWrap library
|
5. Preparation of the environment after installation
12 |
# chmod +w /usr/local/mysql/ # chown -R mysql:mysql /usr/local/mysql/ |
6. Copy the configuration file and modify
1 |
# cp support-files/my-large.cnf /etc/my.cnf |
Add the following:
1234 |
datadir = /data/mysql/ 3306 /data innodb_flush_log_at_trx_commit = 2 innodb_file_per_table = ON skip_name_resolve = ON |
To view the configuration file:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
vim /etc/my.cnf
[client]
port =
3306
socket = /tmp/mysql.sock
[mysqld]
port =
3306
socket = /tmp/mysql.sock
skip-external-locking
key_buffer_size = 256M
max_allowed_packet = 1M
table_open_cache =
256
sort_buffer_size = 1M
read_buffer_size = 1M
read_rnd_buffer_size = 4M
myisam_sort_buffer_size = 64M
thread_cache_size =
8
query_cache_size= 16M
thread_concurrency =
8
log-bin=mysql-bin
binlog_format=mixed
server-id =
1
datadir = /data/mysql/
3306
/data
innodb_data_home_dir = /data/mysql/
3306
/data
innodb_data_file_path = ibdata1:10M:autoextend
innodb_log_group_home_dir = /data/mysql/
3306
/data
innodb_buffer_pool_size = 256M
innodb_additional_mem_pool_size = 20M
innodb_log_file_size = 64M
innodb_log_buffer_size = 8M
innodb_flush_log_at_trx_commit =
2
innodb_lock_wait_timeout =
50
innodb_file_per_table = ON
skip_name_resolve = ON
[mysqldump]
quick
max_allowed_packet = 16M
[mysql]
no-auto-rehash [myisamchk]
key_buffer_size = 128M
sort_buffer_size = 128M
read_buffer = 2M
write_buffer = 2M
[mysqlhotcopy]
interactive-timeout
|
7. Initialize MySQL
1 |
# scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/data/mysql/ 3306 /data/ --defaults-file=/etc/my.cnf |
To view the results of the initialization:
123 |
# ls /data/mysql/ 3306 /data/ aria_log. 00000001 ibdata1 ib_logfile1 mysql-bin. 000001 mysql-bin. 000003 mysql-bin.state test aria_log_control ib_logfile0 mysql mysql-bin. 000002 mysql-bin.index performance_schema |
8. Start the service
1234 |
# cp support-files/mysql.server /etc/rc.d/init.d/mysqld # chmod +x /etc/rc.d/init.d/mysqld # chkconfig --add mysqld # service mysqld start |
9. Add Environment variables
12 |
# vim /etc/profile export PATH=$PATH:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/usr/local/mysql/bin |
Reread environment variables
10. Initializing the Database user table
12345678910 |
# mysql
Welcome to the MariaDB monitor. Commands end
with
; or \g.
Your MariaDB connection id
is
4
Server version:
10.1
.
22
-MariaDB Source distribution
Copyright (c)
2000
,
2016
, Oracle, MariaDB Corporation Ab and others.
Type
'help;'
or
'\h'
for
help. Type
'\c' to clear the current input statement.
MariaDB [(none)]>
use
mysql
Database changed
MariaDB [mysql]>
delete
from user where host=
'localhost.localdomain'
or host=
'127.0.0.1'
or host=
'::1'
or user=
''
;
Query OK,
5
rows affected (
0.00
sec)
|
http://blog.51cto.com/ckl893/1920592
CentOS 7 Compile and install Mariadb-10.2.11