Compile and install the latest mysql bitsCN.com in LINUX
Compile and install the latest mysql version in LINUX
1.download and install mysql-5.5.30.tar.gzand cmake.2.8.11.2.tar.gz
(1) install cmake first (after mysql5.5 is compiled through cmake)
[Root @ rhel5 local] # tar-zxv-f cmake-2.8.11.2.tar.gz
[Root @ rhel5 local] # cd cmake-2.8.11.2
[Root @ rhel5 cmake-2.8.4] #./configure
[Root @ rhel5 cmake-2.8.4] # make
[Root @ rhel5 cmake-2.8.4] # make install
In the configure cmake process, the error message "Cannot find appropriate C ++ compiler on this system" may appear, indicating that the c ++ compiler is missing and therefore is installed.
Yum-y install gcc-c ++
(2) create the mysql installation directory and database storage directory
[Root @ rhel5 ~] # Mkdir-p/usr/local/mysql // install mysql
[Root @ rhel5 ~] # Mkdir-p/usr/local/mysql/data // store the database
(3) Create mysql users and user groups
[Root @ rhel5 ~] Groupadd mysql
[Root @ rhel5 ~] Useradd-r-g mysql
(4) install mysql
[Root @ rhel5 local] # tar-zxv-f mysql-5.5.30.tar.gz
[Root @ rhel5 local] # cd mysql-5.5.30
[Root @ rhel5 mysql-5.5.10] # cmake.
-DCMAKE_INSTALL_PREFIX =/usr/local/mysql
-DMYSQL_DATADIR =/usr/local/mysql/data
-DDEFAULT_CHARSET = utf8 (optional)
-DDEFAULT_COLLATION = utf8_general_ci (optional)
-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 // use the utf8 character
-DDEFAULT_COLLATION = utf8_general_ci // Check the character
-DEXTRA_CHARSETS = all // install all extended character sets
-DENABLED_LOCAL_INFILE = 1 // allow local data import
Note:
During re-compilation, 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
[Root @ rhel5 ~] # Cd/usr/local/mysql
[Root @ rhel5 mysql] # chown-R root: mysql. // Set the owner of all files in the current directory to root and the group to mysql.
[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 service
(3) create a table for the system database
[Root @ rhel5 mysql] # cd/usr/local/mysql
[Root @ rhel5 mysql] # scripts/mysql_install_db -- user = mysql // This is required. this is the initialization of the database. otherwise, many warnings and errors will be prompted.
(4) set environment variables
[Root @ rhel5 ~] # Vi/root/. bash_profile
Add the following parameter in PATH = $ PATH: $ HOME/bin:
PATH = $ PATH: $ HOME/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 cannot stop
Startup logs are written in this file:/usr/local/mysql/data/localhost. err (all information prompted during mysql startup, including error information)
Disable MySQL service
[Root @ rhel5 mysql] # mysqladmin-u root-p shutdown // the root user of MySQL has not configured a password, so it is null. When you need to enter the password, click the enter key.
(6) Another simple method for starting mysql (mysql has been added to the system service)
[Root @ rhel5 ~] # Service mysql. server start
[Root @ rhel5 ~] # Service mysql. server stop
[Root @ rhel5 ~] # Service mysql. server restart
If the preceding command appears: mysql. server does not recognize other services
Maybe mysql has not been added to the system service, and you can add it in another way:
[Root @ rhel5 mysql] # cp support-files/mysql. server/etc/init. d/mysql // add the mysql startup service to the system service
Note: copy mysql. server to/etc/init. d and name it mysql. In some systems, mysql. server in/usr/local/mysql/share/mysql. server, and mysql in the system. server in/usr/local/mysql/support-files/mysql. server.
Then start mysql with # service mysql start.
(7) modify the password of the root user of MySQL and enable remote connection.
[Root @ rhel5 ~] # Mysql-u root mysql
Mysql> use mysql;
Mysql> desc user;
Mysql> grant all privileges on *. * TO root @ "%" identified by "root"; // add the remote connection capability TO the root user.
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
Log On Again: mysql-u root-p
If remote connection is not available, disable the firewall.
[Root @ rhel5 ~] #/Etc/rc. d/init. d/iptables stop
Note: If the remote connection fails and the mysql error number 1130 is displayed, add the following statement:
Mysql> grant all privileges on *. * TO 'root' @ '% 'identified BY' ****** 'with grant option;
BitsCN.com