CentOS6.5 - yum對Mysql的安裝與配置

來源:互聯網
上載者:User

標籤:local   art   put   color   inpu   推薦   使用者   刪除   ide   

一.mysql的安裝

  1.查看是否安裝mysql

  [[email protected] ~]# rpm -qa | grep mysql

   

  如果有進行卸載(以下三種方式選一種即可):

  1)rpm -e mysql-libs-5.1.71-1.el6.x86_64   //普通刪除模式  2)rpm -e --nodeps mysql-libs-5.1.71-1.el6.x86_64    // 強力刪除模式,如果使用上面命令1)刪除時,提示有依賴的其它檔案,則用該命令可以對其進行強力刪除(推薦)  3)yum remove mysql-libs-5.1.71-1.el6.x86_64    //yum卸載

   我選擇的第二種命令卸載

  

  2.進行安裝 : yum -y install mysql-server

  [[email protected] database]# yum -y install mysql-server

   

  

二.mysql資料庫的初始化及相關配置

  1.啟動mysql服務:service mysqld start

  [[email protected] database]# service mysqld start

  

  2.嘗試串連mysql:mysql

  [[email protected] database]# mysql

    

  3.停止:、\q

  

  4.設定mysql開機啟動:chkconfig mysqld on

  [[email protected] database]# chkconfig mysqld on

   5.開啟3306連接埠並儲存

  /sbin/iptables -I INPUT -p tcp --dport 3306 -j ACCEPT    /etc/rc.d/init.d/iptables save

  [[email protected] database]# /sbin/iptables -I INPUT -p tcp --dport 3306 -j ACCEPT  [[email protected] database]# /etc/rc.d/init.d/iptables save

   

   查看mysql是否是3306連接埠:netstat -anp

  [[email protected] database]# netstat -anp

  

  6.設定MySQL的root使用者、密碼

  [[email protected] database]# use mysql;  mysql> set password for [email protected]=password(‘root‘);  或者:  /usr/bin/mysqladmin -u root password ‘new-password‘  // 為root帳號設定密碼

   

  7.設定Mysql遠端存取 grant all privileges on *.* to ‘root‘@‘%‘ identified by ‘123456‘ with grant option;

  mysql> grant all privileges on *.* to ‘root‘@‘%‘ identified by ‘root‘ with grant option;  mysql> FLUSH PRIVILEGES;

   

  安裝完成嘍!!!

 

CentOS6.5 - yum對Mysql的安裝與配置

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.