Environment
The system version is cenos 6.2.
MySQL version: mysql-5.5.11
I. Prepare the environment
1. Create the MySQL installation directory and data storage directory
# Mkdir-P/usr/local/MySQL // install MySQL
# Mkdir-P/usr/local/MySQL/Data // store the database
2. Create myql users and user groups
# Groupadd MySQL
# Useradd-G MySQL
3. Grant data directory storage permission
[# Chown-r root: mysql. // set the owner of all files in the current directory to root and the group to MySQL]
# Chown MYSQL: mysql-r/usr/local/MySQL/Data
4. Install cmake [compiled by cmake after mysql5.5]
You can download cmake-2.8.4.tar.gz on the http://www.cmake.org site, upload and move to the/usr/local directory
# Tar zxvf cmake-2.8.4.tar.gz
# Cd cmake-2.8.4
#./Configure [# gmake]
# Make
# Make instll
Ii. Install MySQL
1. download the latest MySQL version on the MySQL website. Address: http://dev.mysql.com/downloads/mysql/
Upload and move to the/usr/local/MySQL directory
2. Unzip the mysql-5.5.11
# Tar zxvf mysql-5.5.11.tar.gz
# Cd mysql-5.5.11
# 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
# Make
# Make instll
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
4. Set the MySQL startup service as a system service.
# Cp support-files/my-medium.cnf/etc/My. CNF
5. initialize the database
# Cd/user/local/MySQL
# Scripts/mysql_install_db -- user = MySQL -- basedir =/usr/local/MySQL/-- datadir =/usr/local/MySQL/Data
Note: basedir: MySQL installation path datadir: database file storage path
6. Set auto-start upon startup
# Cp support-files/MySQL. Server/etc/init. d/MySQL
# Chmod 755/etc/init. d/MySQL
# Chkconfig MySQL on
7. Configure Environment Variables
Adding the bin directory of MySQL to the path will facilitate future management and maintenance. Adding MySQL/bin to/etc/profile and adding two aliases for easy operation:
# Export Path =/usr/local/MySQL/bin: $ path
# Alias mysql_start = "mysqld_safe &"
# Alias mysql_stop = "mysqladmin-u root-P shutdown"
8. Start the MySQL Service
#/Etc/init. d/MySQL start
Run the PS-Ef | grep MySQL command to check whether the MySQL instance is started.
9. log on to MySQL
# Mysql-u root-P
3. Problems encountered during installation
1.
Solution: Yum install gcc
2.
Solution: Yum install gcc-C ++
3.
Solution:
Yum install ncurse
4. Bash: mysql: Command not find
The reason is that the MySQL command path is under/usr/local/MySQL/bin, so when you directly use the MySQL Command, the system will check this command under/usr/bin, so I cannot find it.
Solution: make a soft link.
# Ln-S/usr/local/MySQL/bin/MySQL/usr/bin
5. If myql cannot be remotely connected and MySQL error number 1130 is displayed, add the following statement:
Mysql> grant all privileges on *. * To 'root' @ '% 'identified by' ****** 'with grant option;
[Note: there is a small problem in the middle, and it will be available later]