mysql安裝等操作

來源:互聯網
上載者:User

標籤:

CentOS 6.5系統中安裝配置MySQL資料庫

卸載掉原有mysql

 rpm -qa | grep mysql  // 這個命令就會查看該作業系統上是否已經安裝了mysql資料庫

rpm -e mysql  // 普通刪除模式

rpm -e --nodeps mysql  // 強力刪除模式

rpm -qa | grep mysql   //命令來查看mysql是否已經卸載成功

注意:安裝mysql時我們並不是安裝了mysql用戶端就相當於安裝好了mysql資料庫了,我們還需要安裝mysql-server服務端才行

yum install -y mysql-server mysql mysql-deve

安裝完成後,瞭解mysql資料庫的初始化及相關配置

service mysqld start  //初始化 MySQL 資料,這時我們會看到第一次啟動mysql伺服器以後會提示非常多的資訊,目的就是對mysql資料庫進行初始化操作,當我們再次重新啟動mysql服務時,就不會提示這麼多資訊了

service mysqld restart

chkconfig --list | grep mysqld

chkconfig mysqld on  //設定開機啟動

mysqladmin -u root password ‘root‘  // 通過該命令給root帳號設定密碼為 root

 mysql -u root -p  // 命令來登入我們的mysql資料庫了

資料庫的主要配置如下:

/etc/my.cnf   這是mysql的主設定檔

/ver/lib/mysql     mysql資料庫的資料庫檔案存放位置

/var/log mysql  資料庫的日誌輸出存放位置

mysql資料庫綁定的連接埠號碼是 3306

netstat -anp | more

 

 

用navicat進行串連會顯示串連錯誤。

 

 

mysql -u root -p  

 

mysql;use mysql;  

 

mysql;select ‘host‘ from user where user=‘root‘;  

 

mysql;update user set host = ‘%‘ where user =‘root‘;  #其中執行這句會報錯,不管它

 

mysql;flush privileges;  

 

mysql;select ‘host‘   from user where user=‘root‘; 

 

再次用navicat開啟串連成功。

 

 

#對應中文翻譯 

 

第一句:以許可權使用者root登入  

 

第二句:選擇mysql庫  

 

第三句:查看mysql庫中的user表的host值(即可進行串連訪問的主機/IP名稱)  

 

第四句:修改host值(以萬用字元%的內容增加主機/IP地址),當然也可以直接增加IP地址  

 

第五句:重新整理MySQL的系統許可權相關表  

 

第六句:再重新查看user表時,有修改。。  

 

重起mysql服務即可完成。

 

忘記mysql資料庫root使用者密碼:

修改MySQL的登入設定

方法一:

vi /etc/my.cnf
加入:skip-grant-tables

重新啟動mysqld 
# /etc/init.d/mysqld restart

 

mysql> USE mysql ;

mysql> UPDATE user SET Password = password ( ‘new-password‘ ) WHERE User = ‘root‘ ;

mysql>flush privileges ;

mysql> quit

#vi /etc/my.cnf
重新啟動mysqld 
# /etc/init.d/mysqld restart

 

方法二:

 

# service mysqld stop
# mysqld_safe --skip-grant-tables --skip-networking &
//注意我們加了--skip-networking,避免遠程無密碼登入MySQL。
# mysql -u root
mysql> use mysql;mysql> update user set password=PASSWORD("mynewpassword") where User=‘root‘;mysql> flush privileges;
mysql > quit
# service mysqld restart
#
mysql -u root -pmynewpassword

注意,-p和密碼間不能有空格。

 
 
 
 



 

 

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.