標籤:style http io ar color os 使用 sp for
首先去http://dev.mysql.com/downloads/mysql/5.5.html#downloads網站下載:
分別下載以下三個檔案(由於我的機器是32位,下面是32位版本的包,如果你的機器是64位的請下載64位版本):
MySQL-server-5.5.16-1.rhel5.i386.rpm
MySQL-client-5.5.16-1.rhel4.i386.rpm
MySQL-devel-5.5.16-1.rhel4.i386.rpm
使用wget命令使用斷點傳輸的方式將這三個檔案下載
wget -c http://dev.mysql.com/get/Downloads/MySQL-5.5/MySQL-server-5.5.16-1.rhel4.i386.rpm/from/http://mysql.spd.co.il/
wget -c http://dev.mysql.com/get/Downloads/MySQL-5.5/MySQL-client-5.5.16-1.rhel4.i386.rpm/from/http://mysql.spd.co.il/
wget -c http://dev.mysql.com/get/Downloads/MySQL-5.5/MySQL-devel-5.5.16-1.rhel4.i386.rpm/from/http://mysql.spd.co.il/
上面的三個檔案,我在安裝的時候,下載非常的慢,下面提供一個雲端硬碟分享的地址:
http://pan.baidu.com/s/1c0kxN0k
(上面的地址需要手動複製粘貼到瀏覽器裡斷行符號開啟)
下載完成後開始安裝:
rpm -ivh MySQL-server-5.5.16-1.rhel4.i386.rpm MySQL-client-5.5.16-1.rhel4.i386.rpm MySQL-devel-5.5.16-1.rhel4.i386.rpm
提示安裝完成後,輸入mysql 看是否安裝成功
mysql
如果出現如下錯誤資訊:
ERROR 2002 (HY000): Can‘t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock‘ (2)
說明mysql服務還沒有啟動,輸入service mysql start啟動mysql服務
service mysql start
然後再輸入mysql,若出現以下提示資訊,說明成功。
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.16 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.
首次安裝時,預設密碼為空白,可以使用如下命令修改root密碼,
mysqladmin -u root password mypassword
mypassword 為你設定的新密碼
然後再次登入
mysql -u root –p
rpm包安裝的MySQL是不會安裝/etc/my.cnf檔案的,解決方案,只需要複製/usr/share/mysql目錄下的my-huge.cnf 檔案到/etc目錄,並改名為my.cnf即可
cp /usr/share/mysql/my-huge.cnf /etc/my.cnf
配置遠端存取
處於安全考慮,Mysql預設是不允許遠端存取的,可以使用下面開啟遠端存取
//賦予任何主機訪問資料的許可權
mysql>GRANT ALL PRIVILEGES ON *.* TO ‘root‘@‘%‘WITH GRANT OPTION
//使修改生效
mysql>FLUSH PRIVILEGES
如果依然不能遠端存取的話,那就很可能防火牆的原因了,可以在防火牆中開啟3306連接埠或者乾脆關掉防火牆。
以上是對自己首次在CentOS上安裝mysql的一個總結,希望對大家有協助。
CentOS下以RPM方式安裝MySQL5.5