Preparatory work
The code is as follows |
Copy Code |
Rpm-qa|grep MySQL RPM-E MySQL yum-y Remove Mysql-server MySQL mysql-libs Yum-y Remove Php-mysql Yum-y Install Yum-fastestmirror #关闭SELinux Vi/etc/selinux/config #将SELINUX =enforcing changed to selinux=disabled Install dependent libraries Yum-y Install Bison gcc gcc-c++ autoconf automake zlib* libxml* ncurses-devel libtool-ltdl-devel* mysql-devel |
Install CMake
Because the mysql5.5 begins, the Configure installation is not used, but the cmake is used.
The code is as follows |
Copy Code |
wget http://www.cmake.org/files/v2.8/cmake-2.8.12.2.tar.gz TAR-ZXVF cmake-2.8.12.2.tar.gz CD cmake-2.8.12.2 ./configure Make && make install Or #yum-y Install CMake |
Download patches and installation packages
The code is as follows |
Copy Code |
#下载mysql-openssl.patch Wget-c "http://bugs.mysql.com/file.php?id=19941&bug_id=68999"-O Mysql-openssl.patch #或 wget-c Http://soft.vpser.net/lnmp/ext/mysql-openssl.patch #下载mysql -5.5.37.tar.gz wget http://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.37.tar.gz installing MySQL using CMake TAR-ZXVF mysql-5.5.37.tar.gz CD mysql-5.5.37 #打补丁 Patch-p1 < ... /mysql-openssl.patch Mkdir/data0/mysql/data #cmake安装配置 the database file address as/data0/mysql/data # CMake Compilation: (-dmysql_datadir=/data0/mysql/data data storage directory) Cmake-dcmake_install_prefix=/usr/local/mysql-dmysql_datadir=/data0/mysql/data-dextra_charsets=all-ddefault_ Charset=utf8-ddefault_collation=utf8_general_ci-dwith_innobase_storage_engine=1-dwith_archive_storage_engine=1 -dwith_blackhole_storage_engine=1-dwith_federated_storage_engine=1-dwith_partition_storage_engine=1-dwith_ Perfschema_storage_engine=1-dmysql_unix_addr=/tmp/mysqld.sock-dmysql_tcp_port=3306-dwith_debug=0-denabled_ Local_infile=1-dwith_readline=1-dwith_ssl=system-dwith_zlib=system-dwith_embedded_server=1 # install MySQL Make && make install |
Copy configuration file
#在support-files Directory has five configuration information files (important here, be sure to copy the corresponding CNF files according to your own memory, otherwise MySQL will never come):
#my-small.cnf (Memory <=64m)
#my-medium.cnf (Memory 128M)
#my-large.cnf (Memory 512M)
#my-huge.cnf (Memory 1g-2g)
#my-innodb-heavy-4g.cnf (Memory 4GB)
Cd/usr/local/mysql
CP./SUPPORT-FILES/MY-INNODB-HEAVY-4G.CNF/ETC/MY.CNF
Modify configuration file
The code is as follows |
Copy Code |
Vi/etc/my.cnf Add or modify #在 [mysqld] section DataDir =/data0/mysql/data Wait-timeout = 30 Default-storage-engine = MyISAM Max_connections = 512 Max_allowed_packet = 16M |
Creating Users and Groups
The code is as follows |
Copy Code |
Groupadd MySQL Useradd-s/sbin/nologin-m-G MySQL MySQL
|
Set permissions
The code is as follows |
Copy Code |
Chown-r Mysql/usr/local/mysql/var (if the database file directory has changes, please operate a specific directory, such as: Chown-r Mysql:mysql/data0/mysql/data) Chgrp-r mysql/usr/local/mysql/.
|
Initializing the database
The code is as follows |
Copy Code |
/usr/local/mysql/scripts/mysql_install_db--defaults-file=/etc/my.cnf--basedir=/usr/local/mysql--datadir=/data0 /mysql/data--user=mysql
|
Configure power-on self-boot
The code is as follows |
Copy Code |
Cp/usr/local/mysql/support-files/mysql.server/etc/init.d/mysql chmod 755/etc/init.d/mysql
|
Set up soft connections
[This step can be skipped.] does not affect use. ]
Make MySQL, mysqldump, mysqladmin, etc. bin commands run directly in the shell
The code is as follows |
Copy Code |
Ln-s/usr/local/mysql/lib/mysql/usr/lib/mysql Ln-s/usr/local/mysql/include/mysql/usr/include/mysql Ln-s/usr/local/mysql/bin/mysql/usr/bin/mysql Ln-s/usr/local/mysql/bin/mysqldump/usr/bin/mysqldump Ln-s/usr/local/mysql/bin/myisamchk/usr/bin/myisamchk Ln-s/usr/local/mysql/bin/mysqld_safe/usr/bin/mysqld_safe Ln-s/usr/local/mysql/bin/mysqladmin/usr/bin/mysqladmin
|
Start MySQL
code is as follows |
copy code |
/etc/init.d/mysql start set MySQL username and password /usr/local/mysql/bin/ mysqladmin-u root password 123456 /usr/local/mysql/bin/mysql-u root-p123456 use MySQL; #update User Set Password=password (' 123456 ') where user= ' root '; Delete from user where not (user= ' root '); Delete from user where user= ' root ' and password= '; Show databases; Drop database test; DROP USER ' @ '%; Flush privileges; Restart MySQL /etc/init.d/mysql Restart Tests whether MySQL starts # 1) To see if there is a process MySQL Ps-ef | grep mysql # 2) to see if the port is running NETST AT-TNL | grep 3306 |