Linux下mysql安裝配置入門知識

來源:互聯網
上載者:User

  1、下載MySQL的Linux安裝檔案

  Linux下安裝MySQL需要下面兩個檔案:

   MySQL-server-5.1.7-0.i386.rpm

  為:http://dev.mysql.com/downloads/mysql/5.1.html,開啟此網頁,下拉網頁找到“Linux x86 generic RPM (statically linked against glibc 2.2.5) downloads”項,找到“Server”和“Client programs”項,下載需要的上述兩個rpm檔案。

  2、Linux下安裝MySQL

   rpm檔案是Red Hat公司開發的軟體安裝包,rpm可讓Linux在安裝軟體包時免除許多複雜的手續。該命令在安裝時常用的參數是 –ivh ,其中i表示將安裝指定的rmp軟體包,V表示安裝時的詳細資料,h表示在安裝期間出現“#”符號來顯示目前的安裝過程。這個符號將持續到安裝完成後才停止。

   1)安裝伺服器端

   在有兩個rmp檔案的目錄下運行如下命令:

   [root@test1 local]# rpm -ivh MySQL-server-5.1.7-0.i386.rpm MySQL-client-5.1.7-0.i386.rpm  

顯示如下資訊。

warning: MySQL-server-5.1.7-0.i386.rpm

signature: NOKEY, key ID 5072e1f5

   Preparing...       ########################################### [100%]

   1:MySQL-server     ########################################### [100%]

    。。。。。。(省略顯示)

   /usr/bin/mysqladmin -u root password 'new-password'

   /usr/bin/mysqladmin -u root -h test1 password 'new-password'

    。。。。。。(省略顯示)

   Starting mysqld daemon with databases from /var/lib/mysql

  如出現如上資訊,服務端安裝完畢。測試是否成功可運行netstat看Mysql連接埠是否開啟,如開啟表示服務已經啟動,安裝成功。Mysql預設的連接埠是3306。

   [root@test1 local]# netstat -nat

   Active Internet connections (servers and established)

   Proto Recv-Q Send-Q Local Address      Foreign Address     State   

   tcp  0  0 0.0.0.0:3306     0.0.0.0:*      LISTEN   

   上面顯示可以看出MySQL服務已經啟動。

   2)安裝用戶端

   運行如下命令:

   [root@test1 local]# rpm -ivh MySQL-client-5.1.7-0.i386.rpm

   warning: MySQL-client-5.1.7-0.i386.rpm: V3 DSA signature: NOKEY, key ID 5072e1f5

   Preparing...    ########################################### [100%]

   1:MySQL-client  ########################################### [100%]

   顯示安裝完畢。

   用下面的命令串連mysql,測試是否成功。

  三、登入MySQL

   登入MySQL的命令是mysql, mysql 的使用文法如下:

   mysql [-u username] [-h host] [-p[password]] [dbname]

   username 與 password 分別是 MySQL 的使用者名稱與密碼,mysql的初始管理帳號是root,沒有密碼,注意:這個root使用者不是Linux的系統使用者。MySQL預設使用者是root,由於初始沒有密碼,第一次進時只需鍵入mysql即可。

   [root@test1 local]# mysql

   Welcome to the MySQL monitor. Commands end with ; or \g.

   Your MySQL connection id is 1 to server version: 4.0.16-standard

   Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

   mysql>

   出現了“mysql>”提示符,恭喜你,安裝成功!

   增加了密碼後的登入格式如下:

   mysql -u root -p

   Enter password: (輸入密碼)

  其中-u後跟的是使用者名稱,-p要求輸入密碼,斷行符號後在輸入密碼處輸入密碼。

  注意:這個mysql檔案在/usr/bin目錄下,與後面講的開機檔案/etc/init.d/mysql不是一個檔案。

  • 1
  • 2
  • 3
  • 下一頁

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.