1. Assuming there are already mysql-5.5.10.tar.gz and cmake-2.8.4.tar.gz two source files
(1) First install CMake (mysql5.5 later is compiled by CMake)
[root@ rhel5 Local] #tar-zxv-f cmake-2.8.4.tar.gz
[root@ rhel5 Local] #cd cmake-2.8.4
[root@ rhel5 cmake-2.8.4]# ./configure
[root@ rhel5 cmake-2.8.4] #make
[root@ rhel5 cmake-2.8.4] #make Install
(2) Create MySQL installation directory and database storage directory
[root@ rhel5~] #mkdir-P/usr/local/mysql //install MySQL
[root@ rhel5~] #mkdir-P/usr/local/mysql/data // storing databases
(3) Create MySQL users and user groups
[root@ rhel5~]groupadd MySQL
[root@ rhel5~]useradd-r-G MySQL MySQL
(4) Install MySQL
[root@ rhel5 Local] #tar-zxv-f mysql-5.5.10.tar.gz
[root@ rhel5 Local] #cd mysql-5.5.10
[root@ rhel5 MYSQL-5.5.10] #cmake.
-dcmake_install_prefix=/usr/local/mysql
-dmysql_datadir=/usr/local/mysql/data
-DDEFAULT_CHARSET=utf8
-ddefault_collation=utf8_general_ci
-dextra_charsets=all
-denabled_local_infile=1
[root@ rhel5 MYSQL-5.5.10] #make
[root@ 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//Checksum character
-dextra_charsets=all//Install all extended character sets
-denabled_local_infile=1//Allow import of data from local
Precautions:
When recompiling, the old object files and cached information need to be purged.
# Make Clean
# rm-f CMakeCache.txt
# RM-RF/ETC/MY.CNF
2. Configure
(1) Set directory permissions
[root@ rhel5~]# cd/usr/local/mysql
[root@ rhel5 mysql]# chown-r.] Set the owner owner of all files in the current directory to root and group to Root:mysql c2/>[root@ rhel5 mysql]# chown-r mysql:mysql data
(2)
[root@ rhel5 mysql]# CP support-files/my-medium.cnf/etc/my.cnf //Add MySQL startup service to system services
(3) Create a table for the system database
[root@ rhel5 mysql]# cd/usr/local/mysql [root@ rhel5 mysql]# scripts/mysql_install_db--user=mysql
(4) Setting environment variables
[root@ rhel5~]# Vi/root/.bash_profile
In path= $PATH: $HOME/bin add parameters to:
Path= $PATH: $HOME/bin:/usr/local/mysql/bin:/usr/local/mysql/lib
[root@ rhel5~] #source/root/.bash_profile
(5) manually start MySQL
[root@ rhel5~]# cd/usr/local/mysql
[root@ rhel5 mysql]#./bin/mysqld_safe--user=mysql &//start MySQL, but can't stop
Startup log is written under this file:/usr/local/mysql/data/localhost.err
Turn off MySQL service
[root@ rhel5 mysql]# mysqladmin-u root-p shutdown //Here the root user of MySQL has not yet been configured with a password, so it is a null value. When you need to enter a password, just click the ENTER key.
(6) Another simple way to start MySQL (MySQL has been added to the system services)
[root@ rhel5~]# service mysql.server start
[root@ rhel5~]# service mysql.server stop
[root@ rhel5~]# service MYSQ L.server restart
If the above command appears: Mysql.server Unrecognized service
It is possible that MySQL has not been added to the system service, and the following is added in another way:
[root@ rhel5 mysql]# CP support-files/mysql.server/etc/init.d/mysql //Add MySQL startup service to system services
Note: The main is the mysql.server copy to the/ETC/INIT.D, named MySQL. In some systems, mysql.server in/usr/local/mysql/share/mysql/mysql.server, and in this system, mysql.server in/usr/local/mysql/ In Support-files/mysql.server.
Then start MySQL with #service MySQL start.
(7) Modify the password of the MySQL root user and open the remote connection
[root@ rhel5~]# mysql-u root mysql
mysql>use MySQL;
Mysql>desc user;
Mysql> GRANT all privileges in *.* to root@ "%" identified by "root"; The ability to add remote connections to root.
mysql>update User Set Password = Password (' xxxxxx ') where user= ' root ';
Mysql>select Host,user,password from User where user= ' root ';
Mysql>flush privileges;
Mysql>exit
Re-logon:mysql-u root-p
If you are not able to connect remotely, turn off the firewall
[root@ rhel5~]#/etc/rc.d/init.d/iptables Stop
Note: If you are unable to connect remotely, and you receive the error MySQL error number 1130, add the following statement to try:
Copy Code code as follows:
Mysql>grant all privileges in *.* to ' root ' @ '% ' of ' identified by ' the ' the ' d ' you ' with GRANT OPTION;
Wonderful topic sharing: MySQL different versions of the installation Tutorials mysql5.7 version Installation Tutorials
The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.