1. Assume that there are already mysql-5.5.10.tar.gz and cmake-2.8.4.tar.gz two source files
(1) Install CMake First (mysql5.5 is compiled by CMake later)
[[email protected] rhel5 Local] #tar-zxv-f cmake-2.8.4.tar.gz
[Email protected] rhel5 Local] #cd cmake-2.8.4
[Email protected] rhel5 cmake-2.8.4]#./configure
[Email protected] rhel5 cmake-2.8.4] #make
[[email protected] rhel5 cmake-2.8.4] #make Install
(2) Create a MySQL installation directory and database storage directory
[[email protected] rhel5~] #mkdir-P/usr/local/mysql
[[email protected] rhel5~] #mkdir-P/usr/local/mysql/data //Storage database
(3) Create MySQL users and user groups
[[email protected] Rhel5~]groupadd MySQL
[[Email protected] rhel5~]useradd-r-g MySQL MySQL
(4) Installing MySQL
[[email protected] rhel5 Local] #tar-zxv-f mysql-5.5.10.tar.gz
[Email protected] rhel5 Local] #cd mysql-5.5.10
-dcmake_install_prefix=/usr/local/mysql
-dmysql_datadir=/usr/local/mysql/data
-ddefault_charset=utf8
-denabled_local_infile=1
[Email protected] rhel5 mysql-5.5.10] #make
[[email protected] rhel5 mysql-5.5.10] #make Install
Parameter description:
-dcmake_install_prefix=/usr/local/mysql//installation directory
-dinstall_datadir=/usr/local/mysql/data//Database storage directory
-ddefault_charset=utf8//using UTF8 characters
-DDEFAULT_COLLATION=UTF8_GENERAL_CI//Check character
-dextra_charsets=all//Install all extended character sets
-denabled_local_infile=1//Allow import of data from local
Precautions:
When you recompile, you need to clear the old object file and cache information.
# Make Clean
# rm-f CMakeCache.txt
# RM-RF/ETC/MY.CNF
2. Configuration
(1) Set directory permissions
[Email protected] rhel5~]# Cd/usr/local/mysql
[Email protected] rhel5 mysql]# chown-r root:mysql. Set the owner owner of all files in the current directory to root, and the owning group is MySQL
[Email protected] rhel5 mysql]# chown-r mysql:mysql data
(2)
[[email protected] RHEL5 mysql]# CP support-files/my-medium.cnf/etc/my.cnf//Add MySQL startup service to system service
(3) Create a table for the system database
[Email protected] rhel5 mysql]# cd/usr/local/mysql
[Email protected] rhel5 mysql]# scripts/mysql_install_db--user=mysql
(4) Setting environment variables
[Email protected] rhel5~]# Vi/root/.bash_profile
In path= $PATH: $HOME/bin add parameters as:
Path= $PATH: $HOME/bin:/usr/local/mysql/bin:/usr/local/mysql/lib
[[email protected] rhel5~] #source/root/.bash_profile
(5) manually start MySQL
[Email protected] rhel5~]# Cd/usr/local/mysql
[[email protected] rhel5 mysql]#./bin/mysqld_safe--user=mysql &//start MySQL, but cannot stop
The boot log is written under this file:/usr/local/mysql/data/localhost.err
Turn off MySQL service
[[email protected] rhel5 mysql]# mysqladmin-u root-p shutdown//Here the root user of MySQL has not configured the password, so it is null. If you need to enter a password, just click Enter.
(6) Another simple way to start MySQL (MySQL has been added to the system service)
[[Email protected] rhel5~]# service Mysql.server start
[[Email protected] rhel5~]# service Mysql.server stop
[Email protected] rhel5~]# service Mysql.server restart
If the above command appears: Mysql.server Unrecognized service
It is possible that MySQL has not been added to the system service, which is added in another way:
[[email protected] RHEL5 mysql]# CP support-files/mysql.server /etc/init.d/mysql//Add MySQL startup service to system service
Note: The main is to copy Mysql.server to/etc/init.d, named MySQL. In some systems, Mysql.server is in/usr/local/mysql/share/mysql/mysql.server, and in this system, mysql.server in/usr/local/mysql/ The Support-files/mysql.server.
Then use #service MySQL start to start MySQL.
(7) Change the password of the root user of MySQL and open the remote connection
[[email protected] rhel5~]# mysql-u root MySQL
Mysql>use MySQL;
Mysql>desc user;
Mysql> GRANT All privileges on * * to [email protected] '% ' identified by ' root '; The ability to add remote connections for root.
Mysql>update user Set Password = Password (' xxxxxx ') where user= ' root ';
Mysql>select Host,user,password
Mysql>flush privileges;
Mysql>exit
Re-login: Mysql-u root-p
If remote connections are not yet in progress, turn off the firewall
[[email protected] rhel5~]#/etc/rc.d/init.d/iptables stop
Note: If you cannot connect remotely, error MySQL error number 1130, then add the following statement to try:
Mysql>grant all privileges on * * to ' root ' @ '% ' identified by ' ****** ' with GRANT OPTION;
Original: http://www.cnblogs.com/fly1988happy/archive/2011/11/21/2257682.html
Linux mysql5.5--Source Installation