CentOS 安裝MySQL

來源:互聯網
上載者:User

鑒於菜鳥,解釋下【安裝mysql】,因為要在linux上使用mysql資料庫,但又不清楚mysql的運行方式,故用個籠統的名詞。

其實,mysql分為mysql server與mysql client,故,這兩個【軟體包】都必須安裝上。

曾經犯的錯誤:

尤其之前不清楚mysql server 與 mysql client,開啟終端後,輸入:mysql,返回無此命令。

然後想當然地使用:

yum install mysql

最後這條能執行,還能安裝(安裝什麼不知道),安裝完成後,用命令:

whereis mysql

還能找到相應的檔案和二進位檔案。但執行:

mysql

出現的是無法開啟 ***** sokcet。(猜測,server沒啟)。

server mysql status

chkconfig --list mysql

都沒有相應的mysql出現,當然也沒有3306連接埠被使用(mysqld的預設連接埠)。

弄了大半天,有些肯定mysql server沒安裝。

總結:

之所以犯這樣的錯誤,主要是沒弄清楚我要mysql工作,需要安裝些什麼軟體,以及沒弄明白一些命令的真正功能(如,yum install msyql)。當然,現在也有許多是一知半解的,如有錯誤,歡迎拍磚。

正確的做法:

1、在官網分別下載mysql server, mysql client。http://www.mysql.com/downloads/mysql/

這裡要注意的地方:

【1】下載時要選擇自己電腦的類型,我選的是:Linux Generic(因為我用圖形介面安裝時,預設選的就是這個)。

【2】要看清楚下載的軟體包,因為那裡面有component, lib等,所以得看清楚(當時我就下了個component),還得分清楚是32位的,還是64位的。

我下載的是:

MySQL-server-5.5.27-1.linux2.6.i386.rpm

MySQL-client-5.5.27-1.linux2.6.i386.rpm

(在終端直接用wget)。

2、安裝mysql server。

在下載的目錄:

rpm -ivh MySQL-server-5.5.27-1.linux2.6.i386.rpm

正常情況會預設安裝好(比較快)。

一般安裝好後,會要修改登入的密碼等(我沒有設定):

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

/usr/bin/mysqladmin -u root -h localhost.localdomain password 'new-password'

Alternatively you can run:

/usr/bin/mysql_secure_installation

which will also give you the option of removing the test

databases and anonymous user created by default.  This is

strongly recommended for production servers.

See the manual for more instructions.

Please report any problems with the /usr/bin/mysqlbug script!

3、安裝mysql client

rpm -ivh MySQL-client-5.5.27-1.linux2.6.i386.rpm

4、啟動mysql server

service mysql start

這時,查看連接埠時,就會發現3306這個連接埠被mysqld佔用著。

[xxh@pc-20101003hbjg ~]$ mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.27 MySQL Community Server (GPL)

Copyright (c) 2000, 2011, 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>

mysql安裝成功,這是就可以用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.