Install MySQL5.6.10 best practices bitsCN. com1 install cmake
MySQL 5.5 and later versions have been replaced by the cmake tool./configure compilation and configuration method.
Therefore, we must first compile and install the cmake tool in the system source code.
# Wget http://www.cmake.org/files/v2.8/cmake-2.8.7.tar.gz
# Tar zxvf cmake-2.8.7.tar.gz
# Cd cmake-2.8.7
#./Configure
# Make
# Make install
1.1cmake command syntax 1.2 when re-compiling, you need to clear the old object file and cache information
# Make clean
# Rm-f CMakeCache.txt
1.3 installation options
The CMAKE_INSTALL_PREFIX value is the basic directory for installation. other cmake option values do not include the prefix or relative path name. The absolute path includes the CMAKE_INSTALL_PREFIX path. For example, the absolute path of-DINSTALL_SBINDIR = sbin is/usr/local/mysql/sbin.
1.4 storage engine options
The mysql storage engine is plug-in-type, so the plug-in control option can specify the storage engine for installation.
Configure compilation plug-in options -- with-plugins = csv, myisam, myisammrg, heap, innobase, archive, and blackhole do not directly correspond to the same options in cmake. For csv, myisam, myisammrg, and heap, you do not need to specify the name of the storage engine in cmake because they are mandatory for installation.
You can use the following options to install the innodb, archive, and blackhole storage engines.
-DWITH_INNOBASE_STORAGE_ENGINE = 1
-DWITH_ARCHIVE_STORAGE_ENGINE = 1
-DWITH_BLACKHOLE_STORAGE_ENGINE = 1
(1 can be replaced by on)
If it is neither-DWITH _ _ STORAGE_ENGINE is not-DWITHOUT _ _ STORAGE_ENGINE is used to specify a storage engine, which is installed as a shared modular storage engine. If it is not shared modular, it will be excluded. You must use the install plugin statement or -- plugin-load to INSTALL the shared module.
For additional information about CMake options for plug-ins, see: http://forge.mysql.com/wiki/MySQL_Internals_Support_for_Plug-Ins
1.5 lib library option 1.6 Other Options
In the past, most MySQL compilation options were supported. The installation options of the new and old versions are mapped to uppercase letters, and the front dashes of the delete option are replaced with underscores. For example:
-- With-debug => WITH_DEBUG = 1
-- With-embedded-server => WITH_EMBEDDED_SERVER
1.7 configuration debugging
After the configure is compiled, the config. log and config. status files are generated.
After cmake is compiled, the CMakeError. log and CMakeOutput. log files are generated in the CMakeFiles directory.
1.8 third-party interface tools
In earlier versions, a third-party tool reads the source configure. in file from the MySQL top-level source directory to determine the mysql version. For example, the AC_INIT line of version 5.5.7-RC looks like this:
AC_INIT ([MySQLServer], [5.5.7-rc], [], [mysql])
The current version can directly read the version file. For example, if the version is 5.5.8, the file looks like this:
MYSQL_VERSION_MAJOR = 5
MYSQL_VERSION_MINOR = 5
MYSQL_VERSION_PATCH = 8
MYSQL_VERSION_EXTRA = rc
If the source package is not GA, the value of MYSQL_VERSION_EXTRA is not empty. For example, for an RC version, the following is true: MYSQL_VERSION_EXTRA = rc.
Build the version number of the five-digit number using the following formula:
MYSQL_VERSION_MAJOR * 10000 + MYSQL_VERSION_MINOR * 100 + MYSQL_VERSION_PATCH
2. verify the installation dependency
Run the rpm-qa | grep name command to verify whether all of the following software packages have been installed.
Gcc * gcc-c ++ * autoconf * automake * zlib * libxml * ncurses-devel * libmcrypt * libtool *
Yum installation example
Example: yum install gcc-c ++
Example: yum install ncurses-devel
If the related software package is missing, you can install it online using yum-y install, or find it directly from the system installation disc and install it using rpm-ivh.
3. system settings before installation
Create the mysql installation directory and data storage directory
# Mkdir/usr/mysql5.5
# Mkdir/usr/mysql5.5/data
Create users and user groups
# Groupadd mysql
# Useradd-gmysql mysql
Grant the data storage directory permission
# Chown mysql: mysql-R/opt/mysql5.5/data
4. start installation (replace configure with cmake)
I believe that most people are used to the configure method and the parameters used are more personalized. after changing to cmake, this will cause a lot of trouble.
Fortunately, the MySQL official website provides a parameter comparison table between the two. we can keep the previous parameters as much as possible to compile and configure the new MySQL version.
Configure and cmake parameters:
Http://forge.mysql.com/wiki/Autotools_to_CMake_Transition_Guide
Take myself as an example. the parameters that I used previously are:
./Configure -- prefix =/opt/mysql //
-- Sysconfdir =/opt/mysql/etc/
-- Localstatedir =/opt/mysql/data/
-- With-tcp-port = 3306/
-- With-unix-socket-path =/tmp/mysqld. sock/
-- With-mysqld-user = mysql/
-- Enable-cycler/
-- With-extra-charsets = all/
-- Enable-thread-safe-client/
-- With-big-tables/
-- With-readline/
-- With-ssl/
-- With-embedded-server/
-- Enable-local-infile/
-- With-plugins = partition, innobase, myisammrg
After comparison with cmake parameters, remove the canceled parameters (most of which are enabled by default in the new version). The cmake parameter configuration is as follows:
Cmake-DCMAKE_INSTALL_PREFIX =/opt/mysql/
-DSYSCONFDIR =/opt/mysql/etc/
-DMYSQL_DATADIR =/opt/mysql/data/
-DMYSQL_TCP_PORT = 3306/
-DMYSQL_UNIX_ADDR =/tmp/mysqld. sock/
-DMYSQL_USER = mysql/
-DEXTRA_CHARSETS = all/
-DWITH_READLINE = 1/
-DWITH_SSL = system/
-DWITH_EMBEDDED_SERVER = 1/
-DENABLED_LOCAL_INFILE = 1/
-DWITH_INNOBASE_STORAGE_ENGINE = 1/
-DWITHOUT_PARTITION_STORAGE_ENGINE = 1
Without line breaks (only one line)
4.1 parameter:-DWITHOUT_PARTITION_STORAGE_ENGINE = 1
The following error occurs when compilation fails on a 64-bit machine: (if an error occurs during Floating point calculation on a 64-bit machine, the corresponding function cannot be found)
Libsql. a (handler. cc. o): In function 'get _ ha_partition (partition_info *)':
/Data/mysql-5.5.14/SQL/handler. cc: 269: undefined reference to 'Ha _ partition: ha_partition (handlerton *, partition_info *)'
/Data/mysql-5.5.14/SQL/handler. cc: 271: undefined reference to 'Ha _ partition: initialize_partition (st_mem_root *)'
Libsql. a (SQL _partition_admin.cc.o): In function 'alter _ table_truncate_partition_statement: execute (THD *)':
/Data/mysql-5.5.14/SQL/SQL _partition_admin.cc: 165: undefinedreference to 'Ha _ partition: truncate_partition (Alter_info *, bool *)'
Collect2: ld returned 1 exit status
Make [2]: *** [SQL/mysqld] Error 1
Make [1]: *** [SQL/CMakeFiles/mysqld. dir/all] Error 2
Make: *** [all] Error 2
4.2 parameter:-DWITH_SSL = bundled
This parameter must be included by default in MySQL 5.6. * and later versions. Otherwise, the compilation will fail. Related posts:
Https://github.com/santisaez/powerstack/issues/49
Use bundled SSL on CentOS-5.
4.3 installation and execution
# Tar xvf mysql-5.5.10.tar.gz
# Cd mysql-5.5.10
# Cmake-DCMAKE_INSTALL_PREFIX =/usr/local/mysql5.5-DSYSCONFDIR =/usr/local/mysql5.5/etc-DMYSQL_DATADIR =/usr/local/mysql5.5/data-DMYSQL_TCP_PORT = connector =/usr/local/mysql5.5 /mysqld. sock-DMYSQL_USER = mysql-DDEFAULT_CHARSET = utf8-DDEFAULT_COLLATION = utf8_general_ci-DEXTRA_CHARSETS = all-DWITH_READLINE = 1-DWITH_SSL = system-keys = 1-keys = 1-DWITH_SSL = bundled
# Make
# Make install
5. settings
# Cd support-files/
Copy the configuration file:
# Cp my-default.cnf/etc/my. cnf
Set automatic start upon startup
# Cp mysql. server/etc/rc. d/init. d/mysqld
5.1 initialize the database
#/Usr/local/mysql5.5/scripts/mysql_install_db -- defaults-file =/etc/my. cnf -- basedir =/usr/local/mysql5.5 -- datadir =/usr/local/mysql5.5data -- user = mysql
5.2 settings
# Vi/etc/init. d/mysqld (edit this file, find and modify the following variable content :)
Basedir =/usr/local/mysql5.5
Datadir =/var/mysql5.5/data
Add a startup item:
# Chkconfig -- add mysqld
# Chkconfig -- level 345 mysqld on
5.3 start the service
# Service mysqld start
If the folder:/usr/local/mysql5.5 is read-only, an error is returned:
...
...
11:12:45 7886 [Note] IPv6 is notavailable.
11:12:45 7886 [Note]-'0. 0.0.0 'resolves to '0. 0.0.0 ';
11:12:45 7886 [Note] Server socketcreated on IP: '0. 0.0.0 '.
2013-04-08 11:12:45 7886 [ERROR] Can't startserver: Bind on unix socket: Permission denied
2013-04-08 11:12:45 7886 [ERROR] Do youalready have another mysqld server running on socket:/usr/local/mysql5.5/mysqld. sock?
11:12:45 7886 [ERROR] Aborting
...
11:12:45 7886 [Note] InnoDB: Starting shutdown...
11:12:47 7886 [Note] InnoDB: Shutdown completed; log sequence number 1626077
11:12:47 7886 [Note] Shutting downplugin 'blackhole'
11:12:47 7886 [Note] Shutting downplugin 'performance _ scheme'
11:12:47 7886 [Note] Shutting downplugin 'Archive'
11:12:47 7886 [Note] Shutting downplugin 'csv'
11:12:47 7886 [Note] Shutting downplugin 'mrg _ myisam'
11:12:47 7886 [Note] Shutting downplugin 'myisam'
11:12:47 7886 [Note] Shutting downplugin 'Memory'
11:12:47 7886 [Note] Shutting downplugin 'sha256 _ password'
11:12:47 7886 [Note] Shutting downplugin 'MySQL _ old_password'
11:12:47 7886 [Note] Shutting downplugin 'MySQL _ native_password'
11:12:47 7886 [Note] Shutting downplugin 'binlog'
11:12:47 7886 [Note]/usr/local/mysql5.5/bin/mysqld: Shutdown complete
130408 11:12:47 mysqld_safe mysqld from pidfile/usr/local/mysql5.5/data/zskw2.pid ended
Solution: Set/usr/local/mysql5.5 to read/write.
...
5.4 set password
#/Usr/local/mysql/bin/mysqladmin password [new-password]
6 database initialization
To make the database accessible remotely, the following user must exist in the mysql user in the database:
Host user password
% Root xxx
7 Appendix
7.1 reference URL
Http://www.centos.bz/2011/09/linux-compile-install-mysql-5-5-15-from-source/
Http://blog.csdn.net/sunjingzhi/article/details/6671668
Https://github.com/santisaez/powerstack/issues/49
Http://heylinux.com/archives/993.html
Http://www.mysqlops.com/2011/03/06/mysql_compile_reference.html
Http://who0168.blog.51cto.com/253401/469898
7.2 my. cnf
# Example MySQLconfig file for large systems.
#
# This is for a largesystem with memory = 512 M where the system runs mainly
# MySQL.
#
# MySQL programs lookfor option files in a set
# Locations whichdepend on the deployment platform.
# You can copy thisoption file to one of those
# Locations. Forinformation about these locations, see:
# Http://dev.mysql.com/doc/mysql/en/option-files.html
#
# In this file, youcan use all long options that a program supports.
# If you want to knowwhich options a program supports, run the program
# With the "-- help" option.
# The followingoptions will be passed to all MySQL clients
[Client]
# Password = your_password
Port = 3306
# Socket =/var/lib/mysql. sock
Socket =/usr/local/mysql5.5/mysqld. sock
# Character-set-server = utf8
# Here followsentries for some specific programs
# The MySQL server
[Mysqld]
Port = 3306
# Socket =/var/lib/mysql. sock
Socket =/usr/local/mysql5.5/mysqld. sock
User = mysql
Skip-external-locking
Key_buffer_size = 256 M
Max_allowed_packet = 1 M
Table_open_cache = 256
Sort_buffer_size = 1 M
Read_buffer_size = 1 M
Read_rnd_buffer_size = 4 M
Myisam_sort_buffer_size = 64 M
Thread_cache_size = 8
Query_cache_size = 16 M
# Try number ofCPU's * 2 for thread_concurrency
Thread_concurrency = 8
# Character-set-server = utf8
Max_connections = 1000
# Don't listen on aTCP/IP port at all. This can be a security enhancement,
# If all processesthat need to connect to mysqld run on the same host.
# All interactionwith mysqld must be made via Unix sockets or named pipes.
# Note that usingthis option without enabling named pipes on Windows
# (Via the "enable-named-pipe" option) will render mysqld useless!
#
# Skip-networking
# Replication MasterServer (default)
# Binary logging isrequired for replication
Log-bin = mysql-bin
# Binary loggingformat-mixed recommended
Binlog_format = mixed
# Required unique idbetween 1 and 2 ^ 32-1
# Defaults to 1 ifmaster-host is not set
# But will notfunction as a master if omitted
Server-id = 1
# Replication Slave (comment out master section to use this)
#
# To configure thishost as a replication slave, you can choose
# Two methods:
#
#1) Use the changemaster to command (fully described in our manual )-
# The syntax is:
#
# Change master to MASTER_HOST = , MASTER_PORT = ,
# MASTER_USER = , MASTER_PASSWORD = ;
#
# Where you replace , , By quoted strings and
# By the master's port number (3306 by default ).
#
# Example:
#
# Change master TOMASTER_HOST = '192. 564.12.1 ', MASTER_PORT = 125,
# MASTER_USER = 'job', MASTER_PASSWORD = 'secret ';
#
# OR
#
#2) Set the variablesbelow. However, in case you choose this method, then
# Start replication for the first time (evenunsuccessfully, for example
# If you mistyped the password inmaster-password and the slave fails
# Connect), the slave will create a master. infofile, and any later
# Change in this file to the variables 'values below will be ignored and
# Overridden by the content of themaster.info file, unless you shutdown
# The slave server, delete master.info andrestart the slaver server.
# For that reason, you may want to leave thelines below untouched
# (Commented) and instead use change masterto (see above)
#
# Required unique idbetween 2 and 2 ^ 32-1
# (And different fromthe master)
# Defaults to 2 ifmaster-host is set
# But will notfunction as a slave if omitted
# Server-id = 2
#
# The replicationmaster for this slave-required
# Master-host =
#
# The username theslave will use for authentication when connecting
# To the master-required
# Master-user =
#
# The password theslave will authenticate with when connecting
# The master-required
# Master-password =
#
# The port the masteris listening on.
# Optional-defaultsto 3306
# Master-port =
#
# Binary logging-notrequired for slaves, but recommended
# Log-bin = mysql-bin
# Uncomment thefollowing if you are using InnoDB tables
# Innodb_data_home_dir =/var/lib/mysql
# Innodb_data_file_path = ibdata1: 10 M: autoextend
# Innodb_log_group_home_dir =/var/lib/mysql
# You can set .. _ buffer_pool_size up to 50-80%
# Of RAM but bewareof setting memory usage too high
# Innodb_buffer_pool_size = 256 M
# Innodb_additional_mem_pool_size = 20 M
# Set .. _ log_file_size to 25% of buffer pool size
# Innodb_log_file_size = 64 M
# Innodb_log_buffer_size = 8 M
# Innodb_flush_log_at_trx_commit = 1
# Innodb_lock_wait_timeout = 50
[Mysqldump]
Quick
Max_allowed_packet = 16 M
[Mysql]
No-auto-rehash
# Remove the nextcomment character if you are not familiar with SQL
# Safe-updates
[Myisamchk]
Key_buffer_size = 128 M
Sort_buffer_size = 128 M
Read_buffer = 2 M
Write_buffer = 2 M
[Mysqlhotcopy]
Interactive-timeout
The original article put here: http://wenku.baidu.com/view/95063fe3b8f67c1cfad6b8fd? Fr = prin. Today, there are a lot of page views. I was too busy to sort them out. today I moved to csdn and hope to share it with more people!
BitsCN.com