One or two binary package installation
MySQL installation Why most of the binary installation is used. Rather than manually compiling the source code?
MySQL is used by glibc for development. GLIBC Library is a low-level API, so as long as Linux, there will be glibc library. Therefore, MySQL installation does not need to consider whether the environment meets the requirements. Portability is convenient. It is also possible to copy the compiled binary code directly onto another machine.
Installed version: mysql-5.6.22-linux-glibc2.5-x86_64.tar.gz
[[email protected] ~]# Groupadd MySQL
[[email protected] ~]# useradd-g MySQL MySQL
Installation steps:
1. Uninstall the old version
Use the following command to check if MySQL Server is installed
[[email protected] ~]# rpm-qa|grep MySQL
Some words are unloaded by the following command
[[email protected] ~]# rpm-e mysql//normal Delete mode
[[email protected] ~]# rpm-e--nodeps MySQL//brute force Delete mode, if you use the above command to delete, prompted to have other dependent files, then use this command can be strongly deleted
2. Unpack the installation package
Generally installed in the/usr/local/directory
[Email protected] ~]# TAR-ZXVF mysql-5.6.22-linux-glibc2.5-x86_64.tar.gz-c/usr/local/
3. Create a soft link
[Email protected] local]# ln-s mysql-5.6.22-linux-glibc2.5-x86_64/mysql
4. Permission Checking and modification
[Email protected] ~]# Cd/usr/local/mysql
[Email protected] mysql]# chown-r mysql.mysql.
5. Initialize the database
[Email protected] mysql]# scripts/mysql_install_db--user=mysql--datadir=/mysql/mysqldata
Note: scripts/mysql_install_db--user=mysql//This is run into MySQL installation directory, so you need to enter the path "scripts/"
Note: Must be performed under the installation directory. You cannot switch to the scripts directory and then execute "./mysql_install_db--user=mysql", otherwise the following error will be reported:
FATAL error:could not find./bin/my_print_defaults
Note, this error is sometimes reported during initialization
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/72/CC/wKiom1XtTUbTIqReAACmVsFx8jg122.jpg "title=" 1.png " alt= "Wkiom1xttubtiqreaacmvsfx8jg122.jpg"/>
Need to install Libaio-devel library
Yum Install-y libaio-devel
6. my.cnf configuration file copy
[email protected] mysql]# CP support-files/my-default.cnf/etc/my.cnf
7. Modify Environment variables
In order to save the environment variables
Add the following/etc/profile file after the
path=/usr/local/mysql/bin/: $PATH
Export PATH
[[email protected] mysql]# source/etc/profile//Refresh environment variable
8. Start MySQL
[[email protected] mysql]# CP support-files/mysql.server/etc/init.d/mysqld// Add service, Copy Service script to INIT.D directory, and set boot start
[[Email protected] mysql]# service mysqld start
Starting MySQL. success!
Second, the source package installation
Installed version: mysql-5.6.24.tar.gz
[[email protected] ~]# Groupadd MySQL
[[email protected] ~]# useradd-g MySQL MySQL
Installation steps:
1. Uninstall the old version
Use the following command to check if MySQL Server is installed
[[email protected] ~]# rpm-qa|grep MySQL
Some words are unloaded by the following command
[[email protected] ~]# rpm-e mysql//normal Delete mode
[[email protected] ~]# rpm-e--nodeps MySQL//brute force Delete mode, if you use the above command to delete, prompted to have other dependent files, then use this command can be strongly deleted
2. Install the installation package required to compile MySQL
MySQL5.5 above to use CMake to compile, so need to install CMake
[Email protected] ~]# yum-y install make gcc-c++ cmake bison-devel ncurses-devel openssl-devel
3. Install MySQL
[Email protected] ~]# TAR-ZXVF mysql-5.6.24.tar.gz
[[Email protected] ~] #cd mysql-5.6.24
[[Email protected] ~] #cmake. -dcmake_install_prefix=/usr/local/mysql \
-dmysql_datadir=/mydata \
-DSYSCONFDIR=/ETC \
-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
Note: If you want to clean up the files generated by the previous compilation, you need to use the following command:
Make clean
RM CMakeCache.txt
[[email protected] ~]# make && make install
The whole process takes about 30 minutes ... A long wait
4. Modify Permissions
[Email protected] mysql]# chown-r mysql.mysql/usr/local/mysql/
5. Initializing the database
[Email protected] mysql]# scripts/mysql_install_db--user=mysql--datadir=/mysql/mysqldata
Note: When starting the MySQL service, will be in a certain order to search my.cnf, first in the/etc directory, find will search "$basedir/my.cnf", in this case is/usr/local/mysql/ MY.CNF, this is the default location for the new MySQL configuration file!
6. my.cnf configuration file copy
[email protected] mysql]# CP support-files/my-default.cnf/etc/my.cnf
Edit VI/ETC/MY.CNF Add the following:
Datadir=/mysql/mysqldata
7. Modify Environment variables
To eliminate the hassle of getting into the directory every time you execute. Add the client's path to the environment variable
Add the following/etc/profile file after the
path=/usr/local/mysql/bin/: $PATH
Export PATH
[[email protected] mysql]# source/etc/profile//Refresh environment variable
8. Start MySQL
[email protected] mysql]# CP support-files/mysql.server/etc/init.d/mysqld //Add service, Copy Service script to INIT.D directory, and set boot start
[[Email protected] mysql]# service mysqld start
Starting MySQL. success!
Linux under MySQL installation (binary package and source package)