1. Download MySQL
Version I downloaded: mysql-5.5.22.tar.gz
2. uninstall MySQL that comes with CentOS before installation
[Root @ localhost ~] # Yum remove mysql
3. Compile and install Cmake
Download cmake source package: http://www.cmake.org/files/v2.8/cmake-2.8.4.tar.gz
Move from shared directory to usr directory
[Root @ localhost ~] # Mv/mnt/hgfs/Share-CentOS/cmake-2.8.4.tar.gz/usr/cmake-2.8.4.tar.gz
[Root @ localhost ~] # Cd/usr
Decompress and install cmake
[Root @ localhost usr] # tar xzvf cmake-2.8.4.tar.gz
[Root @ localhost usr] # cd cmake-2.8.4
[Root @ localhost cmake-2.8.4] #./bootstrap
---------------------------------------------
CMake 2.8.4, Copyright 2000-2009 Kitware, Inc.
---------------------------------------------
Error when bootstrapping CMake:
Cannot find appropriate C compiler on this system.
Please specify one using environment variable CC.
See cmake_bootstrap.log for compilers attempted.
---------------------------------------------
Log of errors:/usr/local/src/cmake-2.8.4/Bootstrap. cmk/cmake_bootstrap.log
---------------------------------------------
Error: C compiler missing
Solution: Install the gcc compiler
[Root @ localhost ~] # Yum install gcc
Continue to install Cmake
[Root @ localhost cmake-2.8.4] #./bootstrap
---------------------------------------------
CMake 2.8.4, Copyright 2000-2009 Kitware, Inc.
C compiler on this system is: cc
---------------------------------------------
Error when bootstrapping CMake:
Cannot find appropriate C ++ compiler on this system.
Please specify one using environment variable CXX.
See cmake_bootstrap.log for compilers attempted.
---------------------------------------------
Log of errors:/usr/local/src/cmake-2.8.4/Bootstrap. cmk/cmake_bootstrap.log
---------------------------------------------
Error: C ++ compiler missing
Solution: Install the gcc-c ++ Compiler
[Root @ localhost ~] # Yum install gcc-c ++
Install again
[Root @ localhost cmake-2.8.4] #./bootstrap
No error reported, compilation and Installation
[Root @ localhost cmake-2.8.4] # gmake
[Root @ localhost cmake-2.8.4] # gmake install
4. start installing MySQL
Add MySQL users and user groups
[Root @ localhost ~] # Groupadd mysql
[Root @ localhost ~] # Useradd-g mysql
Migrate the MySQL source code package from the shared folder to/usr and decompress it.
[Root @ localhost ~] Mv/mnt/hgfs/Share/CentOS/mysql-5.5.22.tar.gz/usr/mysql-5.5.22.tar.gz
[Root @ localhost usr] # tar xzvf mysql-5.5.22.tar.gz
[Root @ localhost usr] # cd mysql-5.5.22
Run Cmake
[Root @ localhost mysql-5.5.22] # cmake.
Start compilation and Installation
[Root @ localhost mysql-5.5.22] # make & make install
Go to the installation directory, change the ownership of the binary program to root, and change the description of the data directory to mysql user to update the authorization table.
[Root @ localhost mysql-5.5.22] # cd/usr/local/mysql/
[Root @ localhost mysql] # chown-R root.
[Root @ localhost mysql] # chown-R mysql.
[Root @ localhost mysql] # chgrp-R mysql.
[Root @ localhost mysql] # scripts/mysql_install_db -- user = mysql
Start MySQL safely (the default password is blank)
[Root @ localhost mysql] #./bin/mysqld_safe -- user = mysql &
Error:
120908 00:16:25 mysqld_safe Logging to '/usr/local/mysql/data/CentOS. err '.
120908 00:16:26 mysqld_safe Starting mysqld daemon with databases from/usr/local/mysql/data
Solution:
[Root @ CentOS ~] # Cd/usr/local/mysql/data
[Root @ CentOS data] # ls-l
Total usage 29744
-Rw ---- 1 mysql root 1585 September 8 00:16 CentOS. err
-Rw ---- 1 mysql 6 September 8 00:16 CentOS. pid
-Rw ---- 1 mysql 18874368 September 8 00:16 ibdata1
-Rw ---- 1 mysql 5242880 September 8 00:16 ib_logfile0
-Rw ---- 1 mysql 5242880 September 8 00:16 ib_logfile1
Drwxr-xr-x 2 mysql 4096 September 8 00:14 mysql
-Rw ---- 1 mysql 27293 September 8 00:14 mysql-bin.000001
-Rw ---- 1 mysql 1031892 September 8 00:14 mysql-bin.000002
-Rw ---- 1 mysql 107 September 8 00:16 mysql-bin.000003
-Rw ---- 1 mysql 57 September 8 00:16 mysql-bin.index
Drwx ------ 2 mysql 4096 September 8 00:14 performance_schema
Drwxr-xr-x 2 mysql 4096 September 8 00:08 test
[Root @ CentOS data] # chgrp-R mysql CentOS. err
[Root @ CentOS data] # ls-l
Total usage 29736
-Rw ---- 1 mysql 1585 September 8 00:16 CentOS. err
-Rw ---- 1 mysql 6 September 8 00:16 CentOS. pid
-Rw ---- 1 mysql 18874368 September 8 00:16 ibdata1
-Rw ---- 1 mysql 5242880 September 8 00:16 ib_logfile0
-Rw ---- 1 mysql 5242880 September 8 00:16 ib_logfile1
Drwxr-xr-x 2 mysql 4096 September 8 00:14 mysql
-Rw ---- 1 mysql 27293 September 8 00:14 mysql-bin.000001
-Rw ---- 1 mysql 1031892 September 8 00:14 mysql-bin.000002
-Rw ---- 1 mysql 107 September 8 00:16 mysql-bin.000003
-Rw ---- 1 mysql 57 September 8 00:16 mysql-bin.index
Drwx ------ 2 mysql 4096 September 8 00:14 performance_schema
Drwxr-xr-x 2 mysql 4096 September 8 00:08 test
Connect to the local MySQL
[Root @ localhost mysql] # mysql-u root-p
Enter password. The default value is null. Press Enter.
Disconnect
Mysql> exit;
Set password for root account
[Root @ localhost ~] # Cd/usr/local/mysql/bin
[Root @ localhost mysql] #./bin/mysqladmin-u root password 123456
Enter Password: 123456
Set the option file and copy the configuration file to/etc.
[Root @ localhost mysql] # cp support-files/my-medium.cnf/etc/mysql. cnf
Set auto-start
[Root @ localhost mysql] # cp support-files/mysql. server/etc/init. d/mysql
[Root @ localhost mysql] # chmod + x/etc/init. d/mysql
Enable and disable Mysql through services
[Root @ localhost ~] # Service mysql start
[Root @ localhost ~] # Service mysql stop
5. After the installation and settings are complete, you only need to start, connect, disconnect, and close the installation. The command is as follows:
[Root @ CentOS mysql] # service mysql start
Starting MySQL .. [OK]
[Root @ CentOS mysql] # mysql-u root-p
Enter password:
Welcome to the MySQL monitor. Commands end with; or \ g.
Your MySQL connection id is 1
Server version: 5.5.22 Source distribution
Copyright (c) 2000,201 1, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
Affiliates. Other names may be trademarks of their respective
Owners.
Type 'help; 'or' \ H' for help. type' \ C' to clear the current input statement.
Mysql> show databases;
+ -------------------- +
| Database |
+ -------------------- +
| Information_schema |
| Mysql |
| Performance_schema |
| Test |
+ -------------------- +
4 rows in set (0.07 sec)
Mysql> exit;
Bye
[Root @ CentOS mysql] # service mysql stop
Shutting down MySQL. [OK]
6. Others:
View the process command ps-ef | grep mysqld
Kill process command kill-9 process number