1. 程式人生 > >centos安裝mysql數據庫

centos安裝mysql數據庫

libs msyql tail secure strong 阿裏雲 lease grant off

a.鏡像自帶安裝

1.查看系統mysql
  rpm -qa | grep mysql

2.強制卸載歷史版本
  
rpm -e --nodeps mysql

3.查看yum源下提供的msyql
 
 
yum list | grep mysql

4.執行安裝
  yum install -y mysql-server mysql mysql-devel
  rpm -qi mysql-server

5.啟動
  service mysqld start

6.修改為開機自啟動
  chkconfig --list | grep mysqld
  chkconfig mysqld on

7.修改root用戶密碼


  mysqladmin -u root password ‘root‘



b.系統鏡像為centos6.5,yum安裝自帶的mysql版本是mysql5.1.37,版本過於老舊,升級到mysql_5.6.37

0.查看並關閉防火墻
  service iptables status
  service iptables stop
  chkconfig iptables off

1.停止服務
  service mysqld stop

2.卸載舊版mysql
  yum remove mysql mysql-*

3.移除命令執行後,可再看看是否有殘余的mysql,輸入命令:
  yum list installed | grep mysql

4.如果有,可輸入命令刪除:
  rum remove mysql-libs

5.下載安裝最新的rpm文件
  rpm -Uvh http://repo.mysql.com/mysql-community-release-el6-5.noarch.rpm

6.安裝MySQL,輸入命令:
  yum install mysql-community-server

7.安裝完成後,輸入命令查看MySQL版本號:
  mysql -V

8.啟動MySQL
  service mysqld start

9.查看mysql啟動級別
  chkconfig --list | grep mysqld

10.修改為開機啟動(關閉防火墻)


  chkconfig mysqld on


11.開放指定ip訪問權限(讓其他計算機遠程訪問)
  #將密碼為password的用戶admin下的,database數據庫的所有表開放給192.168.2.100這個ip
  grant all privileges on database.* to [email protected] identified by ‘password‘;
  #虛擬機一般用下邊這個殘暴的做法,root用戶全部表開放給所有人
  grant all privileges on *.* to [email protected]%‘ identified by ‘root‘;

12.刷新數據庫權限
  flush privileges;


c.阿裏雲上安裝高版本msyql_5.6.16

轉載地址:http://blog.csdn.net/u011627980/article/details/52691799


centos自帶的repo是不會自動更新每個軟件的最新版本,所以無法通過yum方式安裝MySQL的高級版本。
所以,yum -y install mysql mysql-server mysql-devel 無法安裝

1.下載可用mysql
  rpm -Uvh http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm

2.查看可用的msyql安裝資源,可跳過
  grep "mysql.*-community.*"

3.安裝
  yum -y install mysql-community-server
  systemctl enable mysqld

4.開機啟動
  systemctl start mysqld

5.重置密碼
  mysql_secure_installation

centos安裝mysql數據庫