1. 程式人生 > >centos6.5安裝MySQL5.7(使用yum源安裝方法)

centos6.5安裝MySQL5.7(使用yum源安裝方法)

mark mar com client skip 刪除 entos community reg

  • 檢測系統是否已安裝 mysql
    [root@localhost ~]# yum list installed | grep mysql
  • 刪除系統已安裝的 mysql 及其依賴
    [root@localhost ~]# yum -y remove mysql-libs.i686
  • 給CentOS添加rpm源
    wget http://repo.mysql.com//mysql-community-release-el6-5.noarch.rpm
    4.安裝yum源
    [root@localhost ~]# yum install mysql-community-release-el6-5.noarch.rpm
    [root@localhost ~]# yum repolist all | grep mysql
    [root@localhost ~]# yum repolist all | grep mysql
    [root@localhost ~]# yum-config-manager --disable mysql55-community
    [root@localhost ~]# yum-config-manager --disable mysql56-community
    [root@localhost ~]# yum-config-manager --enable mysql57-community-dmr
  • 安裝 MySQL 服務端
    [root@localhost ~]#yum install mysql-community-server
    Dependency Installed:
    mysql-community-client.x86_64 0:5.7.22-1.el6
    mysql-community-common.x86_64 0:5.7.22-1.el6
    mysql-community-libs.x86_64 0:5.7.22-1.el6
  • Complete!
    看到以上結束語句,表示安裝成功

    1. 啟動 mysql 服務
      [root@localhost ~]# service mysqld start
      查看啟動是否成功:
      [root@localhost ~]# service mysqld status
      mysqld (pid 10698) 正在運行...
    2. 修改 root 初始密碼
      我這裏用的是安全模式下進入設置密碼
      [root@localhost ~]#service mysqld stop
      [root@localhost ~]#mysqld_safe –skip-grant-tables &
      重新開一個終端輸入一下命令,然後直接敲enterj鍵:
      [root@localhost ~]#mysql -uroot -p
      進入之後,敲use mysql,用mysql數據庫;
      修改root用戶密碼
      mysql> update user set authentication_string=password(123456) where user=‘root‘;
      註:mysql5.7的密碼字段是authentication_string,不是password
      刷新權限並退出
      mysql> >flush privileges;
      mysql> >quit
      重啟mysql,用密碼123456即可登錄mysql
      [root@localhost ~]# service mysqld restart
      [root@localhost ~]# mysql -u root -p
      Oracle is a registered trademark of Oracle Corporation and/or its
      affiliates. Other names may be trademarks of their respective
      owners.

    Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.

    mysql>
    出現以上內容,登錄成功

    1. 設置mysql開機啟動
      [root@localhost ~]# chkconfig mysqld on
      [root@localhost ~]# chkconfig mysqld status

    centos6.5安裝MySQL5.7(使用yum源安裝方法)