7、mysql的配置和安裝

來源:互聯網
上載者:User

標籤:自動啟動   檔案   collate   put   yum   soft   utf8   匿名使用者   rest   

  1. linux環境下mysql的安裝
    1. sudo yum install mysql-server
  2. 修改設定檔
    1. vim /etc/my.cnf
      1. 添加default-character-set = utf8
  3. 設定mysql隨系統自動啟動
    1.  
    2. 檢查設定是否正確
      1. sudo chkconfig --list mysqld
        1. mysqld          0:off   1:off   2:on    3:on    4:on    5:on    6:off
        2. 2-5都是啟動則ok
  4. 啟動mysql
    1. sudo service mysqld start
      1. 如果出現錯誤 MySQL Daemon failed to start. 請參考
        1. http://blog.csdn.net/u012286517/article/details/50436740

    2. 刪除匿名使用者
      1. select user,host from mysql.user;
        1. +------+--------------------+
        2. | user | host |
        3. +------+--------------------+
        4. | root | 127.0.0.1 |
        5. | | localhost |
        6. | root | localhost |
        7. | | vm\_24\_26\_centos |
        8. | root | vm\_24\_26\_centos |
        9. +------+--------------------+
      2. delete from mysql.user where user=‘‘;
    3. 重新整理一下許可權
      1. flush privileges;
    4. 在防火牆下面開放3306連接埠,開放給外網
      1. sudo vim /etc/sysconfig/iptables
        1. #mysql port
        2.   -A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
      2. 重啟防火牆
        1.  service iptables restart
    5. 重新登入mysql
      1. mysql -u root 
    6. 建立一個非root許可權的賬戶,避免使用root
      1. insert into mysql.user(Host,User,Password)values("localhost","mmall",password("mmall"));
      2. 檢查插入是否正確
        1. select user,host from mysql.user;
          1. +-------+--------------------+
          2. | user | host |
          3. +-------+--------------------+
          4. | root | 127.0.0.1 |
          5. | mmall | localhost |
          6. | root | localhost |
          7. | root | vm\_24\_26\_centos |
          8. +-------+--------------------+
    7. 建立一個資料庫
      1. create database `mmall` default character set utf8 collate utf8_general_ci;
    8. 查看許可權
      1. select * from mysql.user \G
    9. 賦予許可權
      1. 切換資料庫 use mmall;
      2. grant all privileges on mmall.* to [email protected]‘%‘ identified by ‘mmall‘ with grant option;
        1. 注意,此語句可能有錯誤,導致執行下面的許可權查詢的時候出現授權不起作用的現象,可以改為下面的授權語句。
          1. grant all privileges on *.* to [email protected]‘%‘ identified by ‘mmall‘ with grant option;
        2. 請參看
          1. https://bbs.csdn.net/topics/330154879
      3. 可以更微調權限為
        1. grant select,delete,create on mmall.* to [email protected]‘%‘ identified by ‘mmall‘ with grant option;
    10. 重新查看全新
        1. select * from mysql.user \G


    11. 修改root帳號的密碼
      1. set password for [email protected]=password(‘root‘);
      2. set password for [email protected]=password(‘root‘);
      3. select user,host,password from mysql.user;
    12. 退出重新登入
      1. 使用密碼登入,否則沒有許可權
  5. win下安裝mysql    


來自為知筆記(Wiz)

7、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.