日本好好热aⅴ|国产99视频精品免费观看|日本成人aV在线|久热香蕉国产在线

  • <cite id="ikgdy"><table id="ikgdy"></table></cite>
    1. 西西軟件園多重安全檢測(cè)下載網(wǎng)站、值得信賴的軟件下載站!
      軟件
      軟件
      文章
      搜索

      首頁(yè)西西教程數(shù)據(jù)庫(kù)教程 → ubuntu 13.04 安裝mysql數(shù)據(jù)庫(kù)教程

      ubuntu 13.04 安裝mysql數(shù)據(jù)庫(kù)教程

      相關(guān)軟件相關(guān)文章發(fā)表評(píng)論 來(lái)源:西西整理時(shí)間:2013/11/29 22:11:00字體大。A-A+

      作者:西西點(diǎn)擊:33次評(píng)論:1次標(biāo)簽: ubuntu

      PPS for Ubuntu1.0.0.1 官方安裝版
      • 類型:網(wǎng)絡(luò)電視大小:1.5M語(yǔ)言:中文 評(píng)分:6.6
      • 標(biāo)簽:
      立即下載

      Ubuntu是一個(gè)流行的Linux操作系統(tǒng),基于Debian發(fā)行版和GNOME桌面環(huán)境,和其他Linux發(fā)行版相比,Ubuntu非常易用,和Windows相容性很好,非常適合Windows用戶的遷移,預(yù)裝了大量常用軟件,中文版的功能也較全,支持拼音輸入法,預(yù)裝了Firefox、Open Office、多媒體播放、圖像處理等大多數(shù)常用軟件,一般會(huì)自動(dòng)安裝網(wǎng)卡、音效卡等設(shè)備的驅(qū)動(dòng)。

      安裝MySQL

      在Ubuntu上可以使用Ubuntu Software Center或者apt命令來(lái)安裝MySQL,兩種方式都十分方便。

      1. 使用Ubuntu Software Center:打開(kāi)Ubuntu Software Center,在右上角的搜索框查詢mysql,然后選定MySQL Server,點(diǎn)擊安裝即可。

      2. 使用apt:打開(kāi)終端執(zhí)行 ”sudo apt-get install mysql-server“ 即可。

      MySQL初始配置

      MySQL完成安裝后可以直接使用root賬戶登錄,且該賬戶默認(rèn)是沒(méi)有密碼的。注意這里的root角色就是指你的Ubuntu的root角色,如果你當(dāng)前使用的系統(tǒng)帳號(hào)不是root的話,也不必切換到系統(tǒng)root賬戶,可以在登錄MySQL的時(shí)候使用“-u"這個(gè)參數(shù)來(lái)指定登錄賬戶。如:

      $ mysql -u root
      mysql> show databases;
      +--------------------+
      | Database           |
      +--------------------+
      | information_schema |
      | mysql              |
      | performance_schema |
      | test               |
      +--------------------+
      4 rows in set (0.00 sec)
      
      mysql> select Host, User from user;
      +-----------+------------------+
      | Host      | User             |
      +-----------+------------------+
      | 127.0.0.1 | root             |
      | ::1       | root             |
      | iUbuntu   |                  |
      | iUbuntu   | root             |
      | localhost |                  |
      | localhost | debian-sys-maint |
      | localhost | root             |
      +-----------+------------------+
      7 rows in set (0.00 sec)

      因?yàn)榇藭r(shí)root賬戶默認(rèn)沒(méi)有密碼,所以不用輸入密碼就能以root角色登錄并查看所有信息的權(quán)限。如果換成非root角色登錄MySQL,則只擁有部分?jǐn)?shù)據(jù)庫(kù)操作權(quán)限。

      $ mysql
      mysql> show databases;
      +--------------------+
      | Database           |
      +--------------------+
      | information_schema |
      | test               |
      +--------------------+
      2 rows in set (0.00 sec)
      
      mysql> use mysql
      ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'mysql'

      因此MySQL完成安裝后的第一件事就是給root用戶設(shè)置密碼,否則數(shù)據(jù)庫(kù)將毫無(wú)安全可言。

      mysql> GRANT ALL PRIVILEGES ON *.* TO root@localhost IDENTIFIED BY "<password>";

      將以上命令中的<password>替換為你要設(shè)定的密碼,以上命令的意思是對(duì)在本機(jī)(localhost)使用<password>密碼登錄的root用戶賦予所有數(shù)據(jù)庫(kù)的操作權(quán)限。設(shè)置密碼后,如果再以root用戶登錄就需要輸入密碼了,如:

      $ mysql -u root
      ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
      $ mysql -u root -p
      Enter password: 
      Welcome to the MySQL monitor.  Commands end with ; or \g.
      Your MySQL connection id is 75
      Server version: 5.5.34-0ubuntu0.13.10.1 (Ubuntu)
      
      Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
      
      Oracle is a registered trademark of Oracle Corporation and/or its
      affiliates. Other names may be trademarks of their respective
      owners.
      
      Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
      
      mysql> 

      建立數(shù)據(jù)庫(kù)獨(dú)立用戶

      因?yàn)閞oot用戶擁有數(shù)據(jù)庫(kù)的所有操作權(quán)限,所以不能輕易地提供給別人使用。在一個(gè)MySQL實(shí)例中可以創(chuàng)建多個(gè)數(shù)據(jù)庫(kù),這些數(shù)據(jù)庫(kù)可能歸屬于不同項(xiàng)目,每個(gè)數(shù)據(jù)庫(kù)的操作角色也不一樣。對(duì)此可以針對(duì)不同那個(gè)數(shù)據(jù)庫(kù)指定用戶進(jìn)行訪問(wèn)。

      首先使用root角色創(chuàng)建一個(gè)數(shù)據(jù)庫(kù)
      mysql> create database db_web_monitor
      
      然后將這個(gè)數(shù)據(jù)庫(kù)授予一個(gè)叫xavier的用戶使用
      mysql> GRANT ALL PRIVILEGES ON db_web_monitor.* TO xavier@localhost IDENTIFIED BY "xavier";

      這樣就可以使用xavier用戶,密碼為xavier在本機(jī)登錄MySQL操作db_web_monitor數(shù)據(jù)庫(kù)了。

      $ mysql -u xavier
      ERROR 1045 (28000): Access denied for user 'xavier'@'localhost' (using password: NO)
      $ mysql -u xavier -p
      Enter password: 
      Welcome to the MySQL monitor.  Commands end with ; or \g.
      Your MySQL connection id is 77
      Server version: 5.5.34-0ubuntu0.13.10.1 (Ubuntu)
      
      Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
      
      Oracle is a registered trademark of Oracle Corporation and/or its
      affiliates. Other names may be trademarks of their respective
      owners.
      
      Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
      
      mysql> show databases;
      +--------------------+
      | Database           |
      +--------------------+
      | information_schema |
      | db_web_monitor     |
      | test               |
      +--------------------+
      3 rows in set (0.00 sec)
      
      mysql> 

      開(kāi)放遠(yuǎn)程登錄權(quán)限

      1. 首先修改MySQL的配置文件,允許監(jiān)聽(tīng)遠(yuǎn)程登錄。

      $ sudo vi /etc/mysql/my.cnf
      
      找到bind-address所在行
      
       45 # Instead of skip-networking the default is now to listen only on
       46 # localhost which is more compatible and is not less secure.
       47 bind-address        = 127.0.0.1
      
      將 bind-address值修改為本機(jī)IP即可。
      
      注意注釋說(shuō)明,如果是較老版本的MySQL,此處就應(yīng)該是skip-networking,直接將其注釋即可。

      2. 授予用戶遠(yuǎn)程登錄權(quán)限。

      mysql>GRANT ALL PRIVILEGES ON db_web_monitor.* TO xavier@"%" IDENTIFIED BY "xavier";

      如此這般,xavier用戶就可以在任意主機(jī)通過(guò)IP訪問(wèn)到本機(jī)MySQL,對(duì)db_web_monitor數(shù)據(jù)庫(kù)進(jìn)行操作了。

        相關(guān)評(píng)論

        閱讀本文后您有什么感想? 已有人給出評(píng)價(jià)!

        • 8 喜歡喜歡
        • 3 頂
        • 1 難過(guò)難過(guò)
        • 5 囧
        • 3 圍觀圍觀
        • 2 無(wú)聊無(wú)聊

        熱門(mén)評(píng)論

        最新評(píng)論

        發(fā)表評(píng)論 查看所有評(píng)論(1)

        昵稱:
        表情: 高興 可 汗 我不要 害羞 好 下下下 送花 屎 親親
        字?jǐn)?shù): 0/500 (您的評(píng)論需要經(jīng)過(guò)審核才能顯示)