MySQL 5.6.12 database compilation and installation in Linux
MySQL 5.6.12 database compilation and installation in Linux
Download the mysqldata library and download it from the official network. Here, the download is mysql-5.6.12.tar.gz
2. Download cmake, is http://www.cmake.org/files/v2.8/cmake-2.8.12.1.tar.gz
Put the above two software into/usr/local/src.
3. Use yum to install some required packages.
Yum install-y make apr * autoconf automake curl-devel gcc-c ++ gtk +-devel zlib-devel openssl-devel pcre-devel gd kernel keyutils patch perl kernel- headers compat * cpp glibc libgomp libstdc ++-devel keyutils-libs-devel libsepol-devel kernel-devel krb5-devel libXpm * freetype-devel freetype * fontconfig-devel liblibjpeg * libpng * -common php-gd gettext-devel ncurses * libtool * libxml2 libxml2-devel patch policycoreutils bison
4. Compile and install cmake
Cd/usr/local/src
Tar-zxvf cmake-2.8.12.tar.gz
Cd cmake-2.8.12
./Configure
Make
Make install
5. Install mysql
Groupadd mysql # Add a mysql Group
Useradd-g mysql-s/bin/false # Add mysql to mysql group. mysql users are not allowed to log on to the system directly.
Mkdir-p/data/mysql # create a database storage directory
Chown-R mysql: mysql/data/mysql # Set mysql database Directory Permissions
Mkdir-p/usr/local/mysql # create the mysql installation directory
Cd/usr/local/src
The following describes common database configuration options.
-DCMAKE_INSTALL_PREFIX =/usr/local/mysql ---- specify the residual installation path (default value:/usr/local/mysql)
-DMYSQL_DATADIR =/data/mysql ---- mysql data File Path
-DSYSCONFDIR =/etc ---- configuration file path
-DWITH_INNOBASE_STORAGE_ENGINE = 1 ---- use the INNOBASE storage engine
-DWITH_ARCHIVE_STORAGE_ENGINE = 1 ---- It is often used in log record and aggregate analysis, and does not support indexing.
-DWITH_BLACKHOLE_STORAGE_ENGINE = 1 ---- black hole storage engine
-DWITHOUT_EXAMPLE_STORAGE_ENGINE = 1 Describe some storage engine commands during compilation
-DWITHOUT_FEDERATED_STORAGE_ENGINE = 1
-DWITHOUT_PARTITION_STORAGE_ENGINE = 1
-DWITH_READLINE = 1 ---- support batch import of mysql Data
-DWITH_SSL = system ---- mysql supports ssl sessions to implement ssl-based data recovery
-DWITH_ZLIB = system ---- compression library
-DWITH_LIBWRAP = 0 ---- Can I implement access control based on WRAP?
-DMYSQL_TCP_PORT = 3306 ---- default port
-DMYSQL_UNIX_ADDR =/tmp/mysql. sock ---- default socket file path
-DENABLED_LOCAL_INFILE = 1 ---- whether to enable the LOCAL_INFILE Function
-DEXTRA_CHARSETS = all ---- whether additional character sets are supported
-DDEFAULT_CHARSET = utf8 ---- default encoding mechanism
-DDEFAULT_COLLATION = utf8_general_ci ---- set the sorting rules for the default language
-DWITH_DEBUG = 0 ---- DEBUG function settings
-DENABLE_PROFILING = 1 ---- whether the performance analysis function is enabled
Tar-zxvf mysql-5.6.12 # Extract files
Cd mysql-5.6.12
Cmake. -DCMAKE_INSTALL_PREFIX =/usr/local/mysql-DMYSQL_DATADIR =/data/mysql-DSYSCONFDIR =/etc-region = 1-region = 1-region = 1-DWITH_READLINE = 1-DWITH_SSL = bundled-DWITH_ZLIB = bundled-DWITH_LIBWRAP = 0-DMYSQL_UNIX_ADDR =/tmp/mysql. sock-DDEFAULT_CHARSET = utf8-DDEFAULT_COLLATION = utf8_general_ci # Configuration
Make & make install # compile and install
7. cp/support-files/mysql. server/etc/init. d/mysqld # copy the startup script to the/etc/init. d/directory and rename it
8. chmod + x/etc/init. d/mysqld # grant the script execution permission
9. chkconfig -- add mysqld # add as sysV Service
10. chkconfig mysqld on # auto start upon startup
11. /usr/local/mysql/scripts/mysql_install_db -- basedir =/usr/local/mysql -- datadir =/data/mysql -- user = mysql # mysql initialization, basedir develops the installation directory, datadir specifies the data directory And the user specifies the user.
12. Switch cd/data/mysql # To the data directory
Ls # view the generated file
Ibdata1 ib_logfile0 ib_logfile1 mysql performance_schema test # The directory contains the following files.
13. vim/usr/local/mysql/my. cnf # modify the my. cnf file under/usr/local/mysql.
Add the following parameter configuration to set a port and socket.
Binlog-format = ROW
Log-bin = master-bin.log
Log-slave-updates = true
Gtid-mode = on
Enforce-gtid-consistency = true
Master-info-repository = TABLE
Relay-log-info-repository = TABLE
Sync-master-info = 1
Slave-parallel-workers = 2
Binlog-checksum = CRC32
Master-verify-checksum = 1
Slave-SQL-verify-checksum = 1
Binlog-rows-query-log_events = 1
Server-id = 1
Report-port = 3306
Port = 3306
Datadir =/data/mysql
Socket =/tmp/mysql. sock
Report-host = master.magedu.com
14. service mysqld start # start the database
15. Add the mysql command to the global environment variable.
Vim/etc/profile. d/mysql. sh
Export PATH = $ PATH:/usr/local/mysql/bin
16. Re-read environment variables
Source/etc/profile
17. output the mysql man manual to the man command search path.
Vim/etc/man. config
MANPATH/usr/local/mysql/man # Add a row
18. Output mysql library files
Vim/etc/ld. so. conf. d/mysql. conf
Ldconfig-v
/Usr/local/mysql/lib:
Libmysqlclient. so.18-> libmysqlclient_r.so.18.0.0
19. output the mysql header file to the System File
Ln-sv/usr/local/mysql/include // usr/include/mysql
"/Usr/include/mysql"-> "/usr/local/mysql/include /"
20. Test
Netstat-tnlp | grep: 3306
Tcp 0 0: 3306: * LISTEN 17973/mysqld
21. Enter the mysql Command
[Root @ localhost mysql] # mysql
Welcome to the MySQL monitor. Commands end with; or \ g.
Your MySQL connection id is 2
Server version: 5.6.12-log Source distribution
Copyright (c) 2000,201 3, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
Affiliates. Other names may be trademarks of their respective
Owners.
Type 'help; 'or' \ H' for help. type' \ C' to clear the current input statement.
Mysql> show databases;
+ -------------------- +
| Database |
+ -------------------- +
| Information_schema |
| Mysql |
| Performance_schema |
| Test |
+ -------------------- +
4 rows in set (0.22 sec)
This article permanently updates the link address: