1.安裝cmake
    (1)www.cmake.org下載最新包。
    (2)編譯安裝
        ./bootstrap (第一次安裝,如果已安裝cmake;可以使用cmake cmake解壓目錄)
        make
        make install
2.安裝MySql
    (1)創(chuàng)建帳號(hào)
        groupadd mysql
        useradd -r -g mysql mysql
    (2)解壓并編譯安裝
        tar zxvf mysql-VERSION.tar.gz
        cd mysql-VERSION
        // cmake [-DCMAKE_INSTALL_PREFIX=dir_name -DDEFAULT_CHARSET=charset_name -DDEFAULT_COLLATION=collation_name](optional) .
        cmake -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci .
        (charset: utf8; collation: utf8_general_ci)
        make
        make install
    (3)設(shè)置mysql安裝目錄的歸檔信息
        cd /usr/local/mysql
        chown -R mysql .
        chgrp -R mysql .
        chown -R root .
        chown -R mysql data
    (5)安裝數(shù)據(jù)庫(kù)
        scripts/mysql_install_db --user=mysql
    (6)替換my.cnf文件
        cp support-files/my-medium.cnf /etc/my.cnf
    (7)啟動(dòng)MySQL
        nohup bin/mysqld_safe --user=mysql &
        如果啟動(dòng)不成功,執(zhí)行以下命令:
        cat data/localhost.localdomain.err
        如果出現(xiàn)12步的問(wèn)題,可能是數(shù)據(jù)庫(kù)沒(méi)有安裝成功,重新執(zhí)行第5步;然后重新執(zhí)行第7步。
    (8)對(duì)于生產(chǎn)環(huán)境來(lái)說(shuō),還需要做以下操作
        ./bin/mysqladmin -u root password 'new-password'
        ./bin/mysqladmin -u root -h localhost.localdomain password 'new-password'
        或
        ./bin/mysql_secure_installation
    (9)設(shè)置系統(tǒng)啟動(dòng)時(shí),啟動(dòng)MySQL
        cp support-files/mysql.server /etc/init.d/mysql
        chmod +x /etc/init.d/mysql
        chkconfig --add /etc/init.d/mysql
    (10)創(chuàng)建用戶并授權(quán)遠(yuǎn)程訪問(wèn)
        ./bin/mysql -u root -p (進(jìn)入mysql命令行)    
        insert into mysql.user(host, user, password) values ("localhost", "mysql", password("123456"));
        grant all privileges on *.* to 'mysql'@'%' identified by '123456';
        flush privileges;
    (11)配置iptables,開放mysql端口
        vi /etc/sysconfig/iptables
        在COMMIT前,添加下面這句話:
            -A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
        service iptables save
        service iptables restart
    (12)解決以下問(wèn)題
        (10.1)/usr/local/mysql/bin/mysqld: Table 'mysql.plugin' doesn't exist
        (10.2)[ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.host' doesn't exist
        
        出現(xiàn)以上問(wèn)題,是由于mysql_install_db安裝不對(duì),請(qǐng)重新安裝。
        
        
        
    注:1.查找mysql_install_db的位置
        find / -name mysql_install_db
        
        
    Installing MySQL system tables...
    OK
    Filling help tables...
    OK
    
    To start mysqld at boot time you have to copy
    support-files/mysql.server to the right place for your system
    
    PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
    To do so, start the server, then issue the following commands:
    
    ./bin/mysqladmin -u root password 'new-password'
    ./bin/mysqladmin -u root -h localhost.localdomain password 'new-password'
    
    Alternatively you can run:
    ./bin/mysql_secure_installation
    
    which will also give you the option of removing the test
    databases and anonymous user created by default.  This is
    strongly recommended for production servers.
    
    See the manual for more instructions.
    
    You can start the MySQL daemon with:
    cd . ; ./bin/mysqld_safe &
    
    You can test the MySQL daemon with mysql-test-run.pl
    cd ./mysql-test ; perl mysql-test-run.pl
    
    Please report any problems with the ./bin/mysqlbug script!