1:下載社區版的mysql,
要下載兩個文件,分別爲:MySQL-server-community-5.1.46-1.rhel5.i386.rpm
MySQL-client-community-5.1.46-1.rhel5.i386.rpm
客戶端和服務器
下載地址頁:http://www.mysql.com/downloads/mysql/#downloads
2:安裝服務器:
(1)在當前安裝文件目錄下,執行命令,
[root@localhost ~]#rpm -ivh MySQL-server-community-5.1.46-1.rhel5.i386.rpm
注:rpm文件是Red Hat公司開發的軟件安裝包,rpm可讓Linux在安裝軟件包時免除許多複雜的手續。該命令在安裝時常用的參數 是–ivh ,其中i表示將安裝指定的rmp軟件包,V表示安裝時的詳細信息,h表示在安裝期間出現“#”符號來顯示目前的安裝過程。這個符號將持續到安裝完成後才停止。
此步驟出現的錯誤:
error: Failed dependencies:
mysql is needed by bind-9.5.0-16.a6.fc8.i386
象這樣類型的錯誤很有可能是你係統裏面安裝了與現在的版本相沖突的軟件包,或者是缺少關聯包
安裝時顯示如下信息。
warning: MySQL-server-4.0.16-0.i386.rpm: V3 DSA 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@localhost ~]#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服務已經啓動。
3:安裝客戶端:
運行如下命令:
[root@localhost ~]# MySQL-client-community-5.1.46-1.rhel5.i386.rpm
顯示的安裝信息如下:
warning: MySQL-client-4.0.16-0.i386.rpm: V3 DSA signature: NOKEY, key ID 5072e1f5
Preparing... ########################################### [100%]
1:MySQL-client ########################################### [100%]
顯示安裝完畢。
4:修改登陸密碼:
MySQL默認沒有密碼,
2、例子
例
(1):給root加個密碼123456。
[root@localhost ~]# /usr/bin/mysqladmin -u root password 123456
注:因爲開始時root沒有密碼,所以-p舊密碼一項就可以省略了。
(2):用修改後的密碼登錄
[root@localhost ~]# mysql -u root -p
Enter password: (輸入修改後的密碼123456)
Welcome to the MySQL monitor. Commands end with ; or //g.
Your MySQL connection id is 4 to server version: 4.0.16-standard
Type /'help;/' or /'//h/' for help. Type /'//c/' to clear the buffer.
mysql>
成功!
5:啓動服務;
[root@localhost ~]# /etc/init.d/mysql start
6:停止服務:
[root@localhost ~]# /usr/bin/mysqladmin -u root -p shutdown
7:自動啓動
1)察看mysql是否在自動啓動列表中
[root@test1 local]# /sbin/chkconfig –list
2)把MySQL添加到你係統的啓動服務組裏面去
[root@test1 local]# /sbin/chkconfig – add mysql
3)把MySQL從啓動服務組裏面刪除。
[root@test1 local]# /sbin/chkconfig – del mysql
以上就是安裝mysql的基本操作步驟,其它詳細資料可以查找資料