1辈末、文件上傳
rz命令上傳即可
2坐梯、MySQL安裝檢查
#ps -ef|grep mysql? 檢查mysql是否有進(jìn)程在運(yùn)行
#rpm -qa|grep mysql? 檢查是否有安裝包安裝砸王,mysql-libs并不是mysql服務(wù)相關(guān)攻旦,可以不用管
3抖格、解壓
#tar -zxvf mysql-5.6.23-linux-glibc2.5-x86_64.tar.gz -C /usr/local/
#mv /usr/local/mysql-5.6.23-linux-glibc2.5-x86_64/ /usr/local/mysql
4乃正、創(chuàng)建用戶(hù)和用戶(hù)組
#groupadd dba
#useradd?? -g dba -G root -d /usr/local/mysql? mysql
#passwd? mysql? //修改mysql用戶(hù)的密碼
5住册、復(fù)制環(huán)境變量文件到mysql的家目錄
#cp? /etc/skel/.*? /usr/local/mysql
6、編輯mysql配置文件
#vi /etc/my.cnf
7瓮具、權(quán)限配置
#chown mysql:dba /etc/my.cnf
#chmod 640 /etc/my.cnf
#chown -R mysql:dba /usr/local/mysql/
#chmod 755 -R? /usr/local/mysql/
8荧飞、創(chuàng)建歸檔目錄
#su - mysql
$mkdir arch
9、執(zhí)行安裝
$scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
10名党、配置mysql服務(wù)并配置開(kāi)機(jī)啟動(dòng)
#cd /usr/local/mysql/
#cp support-files/mysql.server /etc/rc.d/init.d/mysql ? //復(fù)制mysql服務(wù)到自啟動(dòng)目錄并改名
#chmod +x /etc/rc.d/init.d/mysql?? //賦予mysql執(zhí)行權(quán)限
#ll /etc/rc.d/init.d/mysql?? //查看修改的權(quán)限
-rwxr-xr-x. 1 root root 10880 May 11 15:04 /etc/rc.d/init.d/mysql
#chkconfig --del mysql //刪除原有的mysql服務(wù)
#chkconfig --add mysql?? //添加mysql服務(wù)
#chkconfig --level 345 mysql on //設(shè)置開(kāi)機(jī)自啟動(dòng)
11叹阔、啟動(dòng)mysql并初步配置
#su? - mysql
$rm -rf? my.cnf? //刪除mysql自帶的配置文件,防止影響系統(tǒng)配置/etc/my.cnf
$bin/mysqld_safe &? //安全啟動(dòng)mysql
$mysql? //直接登錄mysql
mysql>use mysql; //切換mysql數(shù)據(jù)庫(kù)
mysql>update user set password=password('123456') where user='root';//設(shè)置密碼
mysql>update user set host='%' where host='localhost';//設(shè)置任意機(jī)器可以訪(fǎng)問(wèn)
mysql>delete from user where user='';//刪除空用戶(hù)
mysql>flush privileges;//刷新權(quán)限
修改環(huán)境變量
$cd ~
$vi .bash_profile
export MYSQL_BASE=/usr/local/mysql
export PATH=$PATH:${MYSQL_BASE}/bin:/usr/kerberos/bin:/opt/bin:/bin:/usr/bin:/usr/local/bin:/usr/bin/X11:/usr/X11R6/bin:/usr/local/mysql
$source .bash_profile
$service mysql start
$mysql -uroot?? -proot
12传睹、mysql新用戶(hù)創(chuàng)建耳幢,創(chuàng)建test用戶(hù),密碼123456欧啤,只能訪(fǎng)問(wèn)newdb庫(kù)睛藻,并限制只能由ip(192.168.137.1)訪(fǎng)問(wèn)
grant all privileges on newdb.* to test@'192.168.137.1' identified by '123456';
flush privileges;
13、show processlist;
查看mysql的所有連接信息邢隧,可以看到id店印,且可以kill? id殺掉連接