The way to install MySQL is: Source package, RPM package (older) and binary package.
Install MySQL 5.1.50:
1. Install dependent packages
#yum-y install gccgcc-c++ ncurses ncurses-devel OpenSSL openssl-devel libtool*
2. Create User:
# Groupadd MySQL
# Useradd Mysql–g Mysql–s/sbin/nologin
3. Install MySQL
# TAR–XVF Mysql-5.1.50.tar.gz
#cd mysql-5.1.50
#./configure '--prefix=/usr/local/services/mysql '--localstatedir=/data/dbdata/'--with-unix-socket-path=/usr/ Local/mysql/tmp/mysql.sock '--with-charset=utf8 '--with-extra-charsets=complex '--with-pthread '-- Enable-thread-safe-client '--with-ssl '--with-client-ldflags=-all-static '--with-mysqld-ldflags=-all-static '- -with-plugins=partition,federated,ndbcluster,innobase,csv,blackhole,myisam,innodb_plugin,heap,archive '-- Enable-shared '--enable-assembler '
# Make && make install
Explain
--prefix Specifying MYSQL installation directory (required)
--localstatedir specifying MySQL data storage directory (required)
--with-unix-socket-path Performing Socke storage location (required)
--with-charset specifying the default character set
--with-extra-charsets can extend complex character sets
--with-pthread forcing the use of the Pthread class library
--enable-thread-safe-client using the compile client; (Let the client support thread meaning)
--WITH-SSL support for SSL enabled
--with-client-ldflags=-all-static statically compiled MySQL client; (static link improves 13% performance)
--with-mysqld-ldflags=-all-static statically compiled MySQL server side; (static link improves 13% performance)
--with-plugins MySQL server-side supported storage engine
--enable-shared Shared Mutation Module
--enable-assembler using assembly mode for increased efficiency
4. Initialization
# mkdir/data/dbdata/
# Chown-r Mysql:mysql/usr/local/services/mysql
# Chown-r mysql:mysql/data/dbdata/
/usr/local/services/mysql/bin/mysql_install_db--user=mysql--basedir=/usr/local/services/mysql--datadir=/data/ dbdata/
# Cp/usr/local/services/mysql/share/mysql/mysql.server/etc/init.d/mysqld
# chmod 755/etc/init.d/mysqld
# Vim/etc/init.d/mysqld
Basedir=/usr/local/services/mysql
datadir=/data/dbdata/
5. Configuration Files
#cp support-files/my-medium.cnf/etc/my.cnf
# VIM/ETC/MY.CNF
6. Start service and SET environment variables
#:vim/etc/profile
Mysql=/usr/local/services/mysql/bin
Path= $PATH: $MYSQL
Export PATH
#source/etc/profile
Start the service
#/etc/init.d/mysqld Start
Mysql5.6 Source Package Installation:
Yum install vim-enhanced cmake gcc gcc-c++ ncurses-devel Bison make-y
Groupadd-g MySQL
Useradd-u 27-g mysql-s/sbin/nologin-m MySQL
Mkdir/database
cmake-dcmake_install_prefix:path=/usr/local/mysql5.6-dmysql_datadir:path=/database/-DSYSCONFDIR:PATH=/usr/ Local/mysql5.6/etc-dwith_debug:bool=on
CMake (-LH) generates CMakeCache.txt and then serves the make
Compilation error deleting CMakeCache.txt after recompilation
Options for man make CMake-l-d
Mysqld D is a group
[[email protected] mysql5.6] #mkdir etc; cp/etc/my.cnf etc/my.cnf
[Mysqld]
basedir=/usr/local/mysql5.6
Datadir=/database
Socket=/var/run/mysqld/mysql5.6.sock
Pid-file=/var/run/mysqld/mysql5.6.pid
User=mysql
PORT=3307 is generally 3306, set 3307 in order to coexist with the RPM package (this is a compilation installation)
The above store customizations are best not to be mixed with other package catalogs
[Mysqld_safe]
Log-error=/var/log/mysqld/mysqld.log
Create a folder that does not exist manually/var/run/mysqld/var/log/mysqld
[[email protected] mysql5.6] #chown-R mysql:mysql/usr/local/mysql5.6/database/var/run/mysqld/var/log/mysqld
[Email protected] mysql5.6]# pwd
/usr/local/mysql5.6
[[email protected] mysql5.6]# vim scripts/mysql_install_db (start)
[Email protected] scripts]# #./mysql_install_db--basedir=/usr/local/mysql5.6/--datadir=/database--user=mysql
-bash:./mysql_install_db: Insufficient permissions (chmod +x mysql_install_db)
(The following file is generated above)
[Email protected] scripts]# ls/database/
Ibdata1 ib_logfile0 ib_logfile1 mysql performance_schema test
[Email protected] support-files]# cp-v mysql.server/etc/rc.d/init.d/mysql5.6
"Mysql.server", "/etc/rc.d/init.d/mysql5.6"
[Email protected] support-files]# vim/etc/init.d/mysql5.6
CONF=/USR/LOCAL/MYSQL5.6/ETC/MY.CNF modification
[Email protected] support-files]# chkconfig--add mysql5.6
[Email protected] support-files]# service mysql5.6 restart
PS aux |grep MySQL # (with root and MySQL user launch separate files)
[[email protected] wan]# ls/var/run/mysqld/# (service start only)
Mysql5.6.pid Mysql5.6.sock
[Email protected] ~]#/usr/local/mysql5.6/bin/mysql
ERROR 2002 (HY000): Can ' t connect to local MySQL server through socket '/tmp/mysql.sock ' (2) #/TMP under NO
[[email protected] ~]# mysql-s/var/run/mysqld/mysql5.6.sock # designation, different from RPM package
# #5.1 Client Login
#/usr/local/mysql5.6/bin/mysql-s/var/lib/mysqld/mysql.sock # 5.6 Client Access 5.1 RPM package yum install MySQL mysql-devel mysql-s erver Php-mysql # service Mysqld restart
Paste the MySQL script installed:
#!/bin/bash#./mysql.sh mysql-5.6.17.tar.gzname1= "$" name2=${name1/.tar.gz/}if ! grep -qi "^mysql" /etc/group; thengroupadd -g 27 mysqlfiif ! id mysql >/dev/null 2>&1; thenuseradd -u 27 -g mysql -s /sbin/ nologin -m mysqlfiyum install -y cmake make gcc gcc-c++ ncurses-devel bison >/dev/null 2>&1[ -d /usr/local/mysql5.6 ] && rm -rf /usr/local/mysql5.6[ -d /database ] && rm -rf /database/* | | mkdir /databaseif [ -d "$name 2" ]; then[ -e "$name 2/ CMakeCache.txt " ] && rm -f " $name 2/cmakecache.txt "elsetar xf " $ Name1 "ficd $name 2#cmake -lh generated cmakecache.txt, make Just press this cache file to compile #man cmakecmake -dcmake_install_prefix:path=/usr/local/mysql5.6 -dmysql_datadir:path=/database -dsysconfdir:path=/usr/local/ mysql5.6/etc -dwith_debug:bool=onmakemake installmkdir /usr/local/mysql5.6/etccat << ! >/usr/local/mysql5.6/etc/my.cnf[mysqld]basedir=/usr/local/mysql5.6datadir=/databasesocket=/var/run/ mysqld/mysql5.6.sockpid-file=/var/run/mysqld/mysql5.6.pidport=3307user=mysql[mysqld_safe]log-error=/var/log/ mysqld/mysql5.6-error.log! [ -d /var/run/mysqld ] && rm -rf /var/run/mysqld/* | | mkdir /var/run/mysqld[ -d /var/log/mysqld ] && rm -rf / var/log/mysqld/* | | mkdir /var/log/mysqldchown -r mysql.mysql /usr/local/mysql5.6 /database / var/run/mysqld /var/log/mysqld/usr/local/mysql5.6/scripts/mysql_install_db --basedir=/usr/local/ mysql5.6 --datadir=/database --user=mysqlcp /usr/local/mysql5.6/support-files/mysql.server /etc/rc.d/init.d/mysql5.6sed -i '/conf=/c conf=/usr/local/mysql5.6/etc/my.cnf ' /etc/rc.d/init.d/mysql5.6chkconfig --add mysql5.6service mysql5.6 start
This article is from the "8430296" blog, please be sure to keep this source http://8440296.blog.51cto.com/8430296/1582118
Installation of two versions of MySQL