1.安裝cmake
(1)www.cmake.org下載最新包。
(2)編譯安裝
./bootstrap (第一次安裝,如果已安裝cmake;可以使用cmake cmake解壓目錄)
make
make install
2.安裝MySql
(1)創建帳號
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)設置mysql安裝目錄的歸檔信息
cd /usr/local/mysql
chown -R mysql .
chgrp -R mysql .
chown -R root .
chown -R mysql data
(5)安裝數據庫
scripts/mysql_install_db --user=mysql
(6)替換my.cnf文件
cp support-files/my-medium.cnf /etc/my.cnf
(7)啟動MySQL
nohup bin/mysqld_safe --user=mysql &
如果啟動不成功,執行以下命令:
cat data/localhost.localdomain.err
如果出現12步的問題,可能是數據庫沒有安裝成功,重新執行第5步;然后重新執行第7步。
(8)對于生產環境來說,還需要做以下操作
./bin/mysqladmin -u root password 'new-password'
./bin/mysqladmin -u root -h localhost.localdomain password 'new-password'
或
./bin/mysql_secure_installation
(9)設置系統啟動時,啟動MySQL
cp support-files/mysql.server /etc/init.d/mysql
chmod +x /etc/init.d/mysql
chkconfig --add /etc/init.d/mysql
(10)創建用戶并授權遠程訪問
./bin/mysql -u root -p (進入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)解決以下問題
(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
出現以上問題,是由于mysql_install_db安裝不對,請重新安裝。
注: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!