Linux下使用MySQL——忘記root密碼及修改MySQL預設編碼

來源:互聯網
上載者:User

標籤:mysql   linux   centos   

概述:

  本部落格不再對MySQL的文法進行講解和說明,想瞭解或熟悉的朋友請自行百度或Google學習。本部落客要是針對MySQL除文法之外的總結,希望能夠也能協助到你。


1.CentOS6.x下MySQL忘記root密碼解決方案

  Ⅰ. 修改MySQL的登入設定

  # vim /etc/my.cnf

  在[mysqld]段中加上一句:skip-grant-tables 


  Ⅱ. 重啟服務

  # service mysqld restart


  Ⅲ. 登入Mysql,修改密碼資訊

  # mysql

  mysql> USE mysql;

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

  mysql> flush privileges;

  mysql> quit


  Ⅳ. 還原Mysql的登入設定

  # vim /etc/my.cnf

  將[mysqld]的段中加上的skip-grant-tables注釋或是刪除


  Ⅴ. 重啟服務

  # service mysqld restart


2.CentOS6.x 修改MySQL預設編碼

  Ⅰ. 登入Mysql查看編碼格式

  show variables like ‘character%‘;


  Ⅱ. 複製my-large.cnf檔案到/etc/my.cnf
  cp /usr/share/doc/mysql-server-4.1.12/my-large.cnf  /etc/my.cnf


  Ⅲ. 編輯my.cnf檔案修改預設編碼格式
  vim /etc/my.cnf
  在[mysqld]段中添加 default-character-set=utf8

  在[client]段中添加 default-character-set=utf8


  Ⅳ. # service mysqld restert # 重啟服務


  Ⅴ. 驗證是否修改成功:show variables like ‘character%‘;


Linux下使用MySQL——忘記root密碼及修改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.