How to install MySQL:
(i) binary format installation:
RPM Installation Package:
OS Vendor, such as the official RPM package provided by Red Hat
MySQL's official RPM package
Generic binary installation package:
(ii) Source code package compilation method Installation:
MySQL Version selection:
So far, the general use of 5.5, which has a lot of features of the new version (just like the 2.6 kernel of Rhel has the characteristics of the 3.x kernel), and the use of the 5.1 version of the style.
But there are still many versions of the official maintenance, such as 5.1, 5.6, 6.x.
Need to compile the installation for hair?
Since the binary format package is compiled on a more general-purpose platform, we need to do some optimizations for our own hardware, or binary packages that provide some of the functionality we don't need, but we need to manually compile the installation.
Compiler:
using CMake as the compiler by default after 5.5 (including), CMake provides more user-friendly progress hints and faster compilation speeds. And one of the most important features is that it is independent of the source code (OUT-OF-SOURCE) of the compilation function, that is, the compilation work can be in another specified directory rather than the source directory, which ensures that the source directory is not affected by any one compilation, As a result, many different compilations can be made on the same source tree, such as for different platforms.
2.6.4 version of CMake is provided by default on CentOS6.4, so you can install cmake directly with Yum. The 2.8 version requires a Epel source installation. If you need to use CMake source to install, you must first use make, the process is as follows:
# Tar XF cmake-2.8.8.tar.gz# cd cmake-2.8.8#/bootstrap not./configure # made # make install
To compile the MySQL installation method:
Now that the compiler has changed, the CMake compiler command must be different from make:
#./configure equivalent to # cmake. #/configure--help equivalent to # CMake. -lh or Ccmake. View Help information
Clean up the files generated by the previous compilation:
# Make clean && rm CMakeCake.txt
Some development packages need to be installed before compiling the installation, because it is a test environment, it is installed:
# yum Groupinstall "Server Platform Development" "Development tools" "Desktop Platform Development" "Desktop debugging a nd performance Tools "" Compatibility Libraries "-Y
To start the installation:
# groupadd -r mysql# useradd -g mysql -r -d /mydata/data mysql the owner of the/mydata/data, the genus Group is set to mysql# tar xf Mysql-5.5.33.tar.gz # cd mysql-5.5.33# cmake . -dcmake_install_prefix=/usr/local /mysql -dmysql_datadir=/mydata/data -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 &Nbsp; -ddefault_collation=utf8_general_ci# make # make install# chown -R .mysql /usr/local/mysql/ Set the genus of/usr/local/mysql to mysql# cp /usr/local/mysql/support-files/my-large.cnf /etc/my.cnf Note: If you are prompted to overwrite in the production environment, please backup and save # vim /etc/my.cnfdatadir = /mydata/datainnodb_file_per_table = 1# cd /usr/local/mysql/# scripts/mysql_ install_db --datadir=/mydata/data/ --user=mysql Initializing MySQL database # cp support-files/mysql.server /etc/init.d/mysqld# chmod +x /etc/ Init.d/mysqld# chkconfig --add mysqld# chkconfig --list mysqld# service mysqld start# ss -antpl | grep :3306# echo "export path=/ Usr/local/mysql/bin: $PATH " > /etc/profile.d/mysqld.sh# source /etc/profile.d/mysqld.sh
Replace the InnoDB engine:
InnoDB belongs to the Innobase company and was later acquired by Oracle. Although the InnoDB engine is free, but its hot backup tool is charged and expensive, so Percona company has made a InnoDB upgrade version xtradb, more powerful, and the Backup tool is free. To do this, Oracle frequently upgrades the MySQL version number, causing Percona to be an illusion of the old version.
We can download the Percona data and then take out the XTRADB engine catalog and name it innobase, then overwrite the/usr/src/mysql-5.5.33/storage/innobase directory, Then follow the normal method according to MySQL.
Post-Installation work:
1. Set root password, delete anonymous user
mysql> use mysqlmysql> Select User,host,password from user;mysql> UPDATE user SET Password=password (' new_passwd ') WHERE user= ' root '; The first way mysql> SET PASSWORD for [email Protected]=password (' new_passwd2 '); The second way mysql> drop user ' @ ' localhost '; mysql> drop user ' @ ' HOSTNAME '; mysql> drop user ' root ' @ ':: 1 '; Disable root login with IPV6
What to do after you forget the root password:
# vim/etc/init.d/mysqld $bindir/mysqld_safe--datadir= "$datadir"--pid-file= "$mysqld _pid_file_path" $other _args > /dev/null 2>&1 & Find this line and then modify it to the following format → save → restart → change root password → restore This file → restart MySQL $bindir/mysqld_safe--datadir= "$datadir "--skip-grant--skip-networking--pid-file=" $mysqld _pid_file_path "$other _args >/dev/null 2>&1 &--s Kip-grant Skip Authorization Form--skip-networking Disable network logon
This article is from the "Go Right on" blog, so be sure to keep this source http://caduke.blog.51cto.com/3365689/1599124
MySQL (4)--Compile and install MySQL-5.5.33