Compile and install MySQL 5.6.16 in CentOS 6.5
Check: uninstall the original MySQL
Because MySQL databases are too popular on Linux, the mainstream Linux system versions currently downloaded are basically integrated with MySQL databases, run the following command to check whether the MySQL database has been installed on the operating system:
Root@CentOS6.5 ~ # Rpm-qa | grep mysql # This command will check whether the mysql database has been installed on the operating system.
If yes, run the rpm-e command or the rpm-e -- nodeps command to uninstall it.
Root@CentOS6.5 ~ # Rpm-e mysql # normal deletion mode [root@CentOS6.5 ~] # Rpm-e -- nodeps mysql # Strong deletion mode. If the above command is used to delete other dependent files, you can use this command to forcibly delete them.
After deletion, run the rpm-qa | grep mysql command to check whether mysql has been uninstalled successfully!
I. Preparations before MySQL compilation and Installation
1. Install the tools and libraries required for compiling source code
yum install gcc gcc-c++ ncurses-devel perl
2. Install cmake, download the source code from the http://www.cmake.org and compile and install
wget http://www.cmake.org/files/v2.8/cmake-2.8.10.2.tar.gztar -xzvf cmake-2.8.10.2.tar.gzcd cmake-2.8.10.2./bootstrap ; make ; make install
2. Set MySQL users and groups
1. New mysql user group
groupadd mysql
2. New mysql users
useradd -r -g mysql mysql
3. Create a directory required by MySQL
1. Create a New mysql installation directory
mkdir -p /usr/local/mysql
2. Create a mysql database data file directory
mkdir -p /data/mysqldb
4. Download and decompress the MySQL source package
Download the source code directly from http://dev.mysql.com/downloads/mysql/
wget http://www.kakapart.com/files/mysql-5.6.16.tar.gz tar -zxv -f mysql-5.6.16.tar.gz cd mysql-5.6.16
V. Compile and install MySQL
1. From mysql5.5 onwards, mysql source code installation began to use cmake, set the source code compilation configuration script.
cmake \ -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \ -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock \ -DDEFAULT_CHARSET=utf8 \ -DDEFAULT_COLLATION=utf8_general_ci \ -DWITH_INNOBASE_STORAGE_ENGINE=1 \ -DWITH_ARCHIVE_STORAGE_ENGINE=1 \ -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \ -DMYSQL_DATADIR=/data/mysqldb \ -DMYSQL_TCP_PORT=3306 \ -DENABLE_DOWNLOADS=1
-DCMAKE_INSTALL_PREFIX = dir_name |
Set the mysql installation directory |
-DMYSQL_UNIX_ADDR = file_name |
Set the listening socket path, which must be an absolute path name. The default value is/tmp/mysql. sock. |
-DDEFAULT_CHARSET = charset_name |
Set the character set of the server. By default, MySQL uses the latin1 (CP1252 Western Europe) Character Set. The cmake/character_sets.cmake file contains a list of allowed character set names. |
-DDEFAULT_COLLATION = collation_name |
Set the server's sorting rules. |
-DWITH_INNOBASE_STORAGE_ENGINE = 1 -DWITH_ARCHIVE_STORAGE_ENGINE = 1 -DWITH_BLACKHOLE_STORAGE_ENGINE = 1 -DWITH_PERFSCHEMA_STORAGE_ENGINE = 1 |
Storage engine options: MyISAM, MERGE, MEMORY, and CSV engines are compiled to the server by default and do not need to be explicitly installed. Statically compile a storage engine to the server and use-DWITH_engine_STORAGE_ENGINE = 1 Available storage engine values include ARCHIVE, BLACKHOLE, EXAMPLE, FEDERATED, INNOBASE (InnoDB), PARTITION (partitioning support), and PERFSCHEMA (Performance Schema) |
-DMYSQL_DATADIR = dir_name |
Set the mysql database file directory |
-DMYSQL_TCP_PORT = port_num |
Set the listening port of the mysql server. The default value is 3306. |
-DENABLE_DOWNLOADS = bool |
Whether to download optional files. For example, if this option is enabled (set to 1), cmake downloads the test suite used by Google to run unit tests. |
Note: delete the cmakecache.txt file after you refresh the configuration.
rm CMakeCache.txt
2. Compile the source code
make
3. Installation
make install
6. Modify the directory owner and group of mysql
1. Modify the mysql installation directory
Cd/usr/local/mysql chown-R mysql: mysql. # Pay Attention to the decimal point after which the current directory cannot be omitted.
2. Modify the mysql database file directory
Cd/data/mysqldb chown-R mysql: mysql. # note the decimal point
VII. initialize the mysql database
cd /usr/local/mysql scripts/mysql_install_db --user=mysql --datadir=/data/mysqldb
8. Copy the mysql service startup configuration file
cp /usr/local/mysql/support-files/my-