First, compile and install MySQL before the preparatory work
Install the tools and libraries needed to compile the source code
[SQL]View Plaincopy
- Yum install gcc gcc-c++ ncurses-devel perl
Install CMake, download the source code from http://www.cmake.org and compile the installation
[SQL]View Plaincopy
- wget http://www.cmake.org/files/v2.8/cmake-2.8.10.2.tar.gz
- TAR-XZVF cmake-2.8.10.2.tar.gz
- CD cmake-2.8.10.2
- ./bootstrap; make; Make install
- CD ~
Second, set up MySQL users and groups
New MySQL user group
[SQL]View Plaincopy
- Groupadd MySQL
New MySQL User
[SQL]View Plaincopy
- Useradd-r-G MySQL MySQL
Iii. directories required for new MySQL
New MySQL installation directory
[SQL]View Plaincopy
- Mkdir-p/usr/Local/mysql
New MySQL database data file directory
[SQL]View Plaincopy
- Mkdir-p/data/mysqldb
Download the MySQL source package and unzip it.
Download the source code directly from http://dev.mysql.com/downloads/mysql/, unzip the mysql-5.6.16.tar.gz (http://www.quseqi.com/This site is used 5.6.16 version)
[SQL]View Plaincopy
- 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
From mysql5.5 onwards, MySQL source installation started using CMake, set the source code compilation configuration script.
Set compilation parameters
[SQL]View Plaincopy
- 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 |
Setting up the MySQL installation directory |
-dmysql_unix_addr=file_name |
Set the listener socket path, which must be an absolute pathname. Default is/tmp/mysql.sock |
-ddefault_charset=charset_name |
Sets the character set of the server. By default, MySQL uses the latin1 (CP1252 Western European) character set. The Cmake/character_sets.cmake file contains a list of allowed character set names. |
-ddefault_collation=collation_name |
Sets the collation of the server. |
-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 the CSV engine is compiled to the server by default and does not need to be explicitly installed.
Statically compiles a storage engine to the server, using-dwith_engine_storage_engine= 1
The available storage engine values are: 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 MySQL server listening port, default to 3306 |
-denable_downloads=bool |
Whether you want to download the optional files. For example, if you enable this option (set to 1), CMake will download the test suite that Google uses to run unit tests. |
Note: To rerun the configuration, you need to delete the CMakeCache.txt file
[SQL]View Plaincopy
- RM CMakeCache.txt
Compiling source code
[SQL]View Plaincopy
- Make
Installation
[SQL]View Plaincopy
- Make install
Vi. modifying MySQL directory Owners and Groups
Modifying the MySQL installation directory
[SQL]View Plaincopy
- cd/usr/Local/mysql
- Chown-r Mysql:mysql.
Modifying the MySQL database file directory
[SQL]View Plaincopy
- Cd/data/mysqldb
- Chown-r Mysql:mysql.
Vii. initializing MySQL Database
[SQL]View Plaincopy
- cd/usr/Local/mysql
- scripts/mysql_install_db --user=mysql--datadir=/data/mysqldb
VIII. copy MySQL service startup configuration file
[SQL]View Plaincopy
- cp/usr/local/mysql/support-files/my-default.cnf/etc/my.cnf
Note: Overwrite if the/etc/my.cnf file exists.
IX. copy MySQL service startup script and join path path
[SQL]View Plaincopy
- CP Support-files/mysql.server/etc/init.d/mysqld
- Vim/etc/profile
- path=/usr/local/mysql/bin:/usr/local/mysql/lib: $PATH
- Export PATH
- Source/etc/profile
Ten. Start the MySQL service and join the boot-up self-boot (Optional This step, you can start your own later)
Service mysqld Start
Chkconfig--level mysqld on
Xi. Check if the MySQL service is started
[SQL]View Plaincopy
- NETSTAT-TULNP | grep 3306
- Mysql-u root-p
The password is empty and if it can be logged on, the installation is successful.
12. Modify the password of the MySQL user root
[SQL]View Plaincopy
- Mysqladmin-u root password ' 123456 '
Note: You can also run the security settings script, modify the password of the MySQL user root, and disable the root remote connection, remove the test database and anonymous users.
[SQL]View Plaincopy
- /usr/local/mysql/bin/mysql_secure_installation
13. Errors that may occur
[SQL]View Plaincopy
- Problem:
- Starting MySQL. The server quit without updating PID file ([failed]/mysql/server03.mylinux.com.pid).
- Solve:
- Modify the DataDir in/etc/my.cnf, point to the correct MySQL database file directory
[SQL]View Plaincopy
- Problem:
- ERROR 2002 (HY000): Can' t connect to local MySQL server through socket '/tmp/mysql.sock ' (2)
- Solve:
- Create a new link or add the-s parameter to MySQL to directly indicate the Mysql.sock location.
- Ln-s/usr/Local/mysql/data/mysql.sock/tmp/mysql.sock
- /usr/local/mysql/bin/mysql-u root-s/usr/local/mysql/data/mysql.sock
[SQL]View Plaincopy
- MySQL Problem resolution:-bash:mysql:command not found
- Because the path to the MySQL command is under/usr/local/mysql/bin, so when you use the MySQL command directly,
- The system checks this command under/usr/bin, so I can't find it.
- The solution is:
- Ln-s/usr/local/mysql/bin/mysql/usr/bin make a link
Linux CentOS6.5 under compile and install MySQL 5.6.16 "give the Force detailed tutorial"