1.安裝MySQL
1.1上傳MYSQL二進(jìn)制軟件包到指定的目錄
# cd /home/oldboy/tools/
# rz -y(上傳MYSQL數(shù)據(jù)庫(kù)的二進(jìn)制軟件包到該目錄下)
1.2 創(chuàng)建mysql用戶和組
#?useradd mysql -s /sbin/nologin -M
1.4 解壓數(shù)據(jù)庫(kù)軟件包并初始化數(shù)據(jù)庫(kù)
# tar xf mysql-5.5.32-linux2.6-x86_64.tar.gz
# mv mysql-5.5.32-linux2.6-x86_64 /application/mysql
或者(# ln -s /home/oldboy/tools/mysql-5.5.32-linux2.6-x86_64/ ???
/application/mysql)
# cd /application/mysql/
# mkdir /application/mysql/data
# chown -R mysql.mysql /application/mysql/data
# ./scripts/mysql_install_db --user=mysql --basedir=/application/mysql/ -- datadir=/application/mysql/data/
# cp support-files/mysql.server /etc/init.d/mysqld
# cp support-files/my-small.cnf /etc/my.cnf
# chmod +x /etc/init.d/mysqld
# vim /etc/init.d/mysqld
#修改mysql配置文件如下內(nèi)容
basedir=/application/mysql
datadir=/application/mysql/data
#保存退出后悔雹,重新啟動(dòng)MYSQL數(shù)據(jù)庫(kù)
# killall mysqld
# /etc/init.d/mysqld start
1.5 給數(shù)據(jù)庫(kù)設(shè)置管理員密碼
# /application/mysql//bin/mysqladmin -u root password 'wpaccp123'
# mysql -uroot -pwpaccp123
1.6 配置MYSQL啟動(dòng)命令的環(huán)境變量
# echo "PATH=/application/mysql/bin:$PATH" >>/etc/profile
# . /etc/profile
或者:(# cp /application/mysql/bin/* /usr/local/sbin/)
1.7 數(shù)據(jù)庫(kù)優(yōu)化
# mysql -uroot -pwpaccp123
mysql> drop database test;
mysql> select user,host from mysql.user
mysql> drop user ''@'wpaccp';
mysql> drop user 'root'@'wpaccp';
mysql> drop user ''@'localhost'
mysql> drop user 'root'@'::1';
mysql> select user,host from mysql.user
提示:如果使用drop命令無(wú)法刪除用戶記錄凡资,需要使用delete命令在mysql.user表下刪除某項(xiàng)記錄
1.8 安裝過程中出現(xiàn)的常見錯(cuò)誤
故障1:當(dāng)使用mysql命令登陸進(jìn)MYSQL數(shù)據(jù)庫(kù)時(shí)嫉称,出現(xiàn)以下錯(cuò)誤
ERROR 2002 (HY000): Can't connect to local Mysql server through socket '/var/lib/mysql/mysql.sock'
解決辦法:
從故障的顯示信息上看反惕,是沒有指定MYSQL的配置文件
??# cp support-files/my-small.cnf /etc/my.cnf
??# /etc/init.d/mysqld start
故障2:當(dāng)執(zhí)行./scripts/mysql_install_db --user=mysql --basedir=/application/mysql/ -- datadir=/application/mysql/data/
這個(gè)命令時(shí)久免,出現(xiàn)以下故障現(xiàn)象
??......
?/application/mysql/bin/mysqld: error while loading share libraries:
?libaio.so.1:cannot open share object file:No such file or directory
?......
解決辦法
?# find / -name "libaio.so.1"
?# yum install libaio-devel -y
故障3:當(dāng)執(zhí)行/etc/init.d/mysqld start后,出現(xiàn)以下故障現(xiàn)象
?Starting MySQL.. ERROR! The server quit without updating PID file
?(/application/mysql/data/client.pid)
解決辦法:
??1)初始化有問題境蔼,最好重新初始化數(shù)據(jù)庫(kù)
??2)啟動(dòng)時(shí)芙委,用來不同的程序啟動(dòng)
??3)沒有配置文件
方法一:
# /application/mysql/bin/mysqld_safe &
# mysqladmin shutdown
故障4:當(dāng)執(zhí)行./scripts/mysql_install_db --user=mysql --basedir=/application/mysql/ -- datadir=/application/mysql/data/
時(shí)出現(xiàn)以下故障現(xiàn)象
?......
ERROR: 1004 Can't reate file '/tmp/#sql61d_1_0.frm'(errno:13)
解決方法:
# chmod -R 4777 /tmp
故障5 當(dāng)執(zhí)行mysql -u root -p mysql命令登陸數(shù)據(jù)庫(kù)時(shí)出現(xiàn)以下故障現(xiàn)象
ERROR 1045 (28000): Access denied for user 'root'@localhost (using password YES)
解決辦法:
初始化DB不正常
# rm -rf /application/mysql/data/
# cd /application/mysql/
# ./scripts/mysql_install_db --user=mysql --basedir=/application/mysql/ -- datadir=/application/mysql/data/
故障6:當(dāng)執(zhí)行./mysql_install_db --user=mysql --basedir=/application/mysql --datadir=/application/mysql/data命令初始化數(shù)據(jù)庫(kù)時(shí).報(bào)錯(cuò)
[root@mysql-db2 scripts]# ./mysql_install_db --user=mysql --basedir=/application/mysql --datadir=/application/mysql/data
FATAL ERROR: please install the following Perl modules before executing ./mysql_install_db:
Data::Dumper
解決辦法:
[root@mysql-db2 scripts]# yum -y install autoconf