02: MySQL的安裝與基本配置

來源:互聯網
上載者:User

標籤:基本   splay   variable   unity   原因   img   事務   ali   密碼   

1.1 MySQL安裝與基本配置(centos 7.3)

  1、使用yum安裝mysql

      yum install mysql-community-server

  2、mysql管理常用命令

      systemctl status mysqld
      systemctl start mysqld
      systemctl stop mysqld

  3、開機啟動

      systemctl enable mysqld
      systemctl daemon-reload

  4、Mysql安裝成功後,預設的root使用者密碼為空白,可以直接登入

      mysql -uroot -p
      mysqladmin -u root password "1"                 # 給root使用者配置密碼:1
      mysql -uroot -p1                                          # 配置完密碼後必須使用密碼登入

 1.2 修改MySQL預設字元集和引擎

  1. 安裝完MySQL使用外部索引鍵關聯建立表失敗,原因是預設引擎不對

  2. MySQL插入中文發現顯示亂碼,原因是預設字元集不對

      show variables like ‘character%‘;                                      #查看MySQL預設字元集

  3. 解決方案是修改MySQL設定檔 vim /etc/my.cnf

vim /etc/my.cnf        #下面的內容都是自己添加的內容[mysqld]default-storage-engine=INNODBdefault_character_set=utf8character_set_server=utf8[mysqld_safe]default-character-set = utf8[client]default-character-set = utf8 [mysql.server]default-character-set = utf8 [mysql]default-character-set = utf8
vim /etc/my.cnf

  4. 面試題:你的資料庫用什麼儲存引擎?區別是?

      1. 常見的有MyISAM和InnoDB。
      2. InnoDB:  支援外鍵約束,支援事務。對索引都是單獨處理的,無需引用索引。
      3. MyISAM: 不支援外鍵約束,不支援事務,對資料大大量匯入時,它會邊插入資料邊建索引。
                           所以為了提高執行效率,應該先禁用索引,在完全匯入後再開啟索引

1.3 MySQL建立使用者與授權

 

02: 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.