Linux作業系統下MySQL的卸載、安裝全過程

來源:互聯網
上載者:User

Linux下卸載MySQL

1、尋找以前是否裝有MySQL

命令:rpm -qa|grep -i MySQL

可以看到MySQL的兩個包:

MySQL-4.1.12-3.RHEL4.1

MySQLclient10-3.23.58-4.RHEL4.1

2、刪除MySQL

刪除命令:rpm -e --nodeps 包名

( rpm -ev MySQL-4.1.12-3.RHEL4.1 )

3、刪除老版本MySQL的開發標頭檔和庫

命令:rm -fr /usr/lib/MySQL

rm -fr /usr/include/MySQL

注意:卸載後/var/lib/MySQL中的資料及/etc/my.cnf不會刪除,如果確定沒用後就手工刪除

rm -f /etc/my.cnf

  rm -fr /var/lib/MySQL


安裝MySQL

安裝前準備:兩個rpm包

MySQL-client-5.1.20-0.glibc23.i386.rpm

MySQL-server-5.1.20-0.glibc23.i386.rpm

1、安裝服務端:

命令:rpm -ivh MySQL-server-5.1.20-0.glibc23.i386.rpm

安裝成功會出現....

warning: MySQL-server-5.1.20-0.glibc23.i386.rpm: V3 DSA signature: NOKEY, key ID 5072e1f5

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

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

080220 13:58:27 [Note] Plugin 'InnoDB' disabled by command line option

080220 13:58:28 [Note] Plugin 'InnoDB' disabled by command line option

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !

To do so, start the server, then issue the following commands:

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

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

See the manual for more instructions.

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

The latest information about MySQL is available on the web at

http://www.MySQL.com

Support MySQL by buying support/licenses at http://shop.MySQL.com

Starting MySQL.[ OK ]

2、安裝用戶端

命令:rpm -ivh MySQL-client-5.1.20-0.glibc23.i386.rpm

成功表現:

[root@localhost ~]# rpm -ivh MySQL-client-5.1.20-0.glibc23.i386.rpm

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

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

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

3、登陸MySQL

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

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

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

[root@localhost ~]# MySQL

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

Your MySQL connection id is 2

Server version: 5.1.20-beta MySQL Community Server (GPL)

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不是一個檔案。

補:

通過rpm包安裝、配置及卸載MySQL的詳細過程.

  以MySQL-server-4.0.14-0.i386.rpm為例,放在/data目錄下

  cd /data

  rpm -ivh MySQL-server-4.0.14-0.i386.rpm

  安裝完成後在/usr/share/MySQL目錄中會有一個MySQL的啟動指令碼MySQL.server及樣本設定檔等(如my-huge.cnf、my-large.cnf、my-medium.cnf)

  拷貝一個樣本設定檔作為MySQL的設定檔:

  cp /usr/share/MySQL/my-medium.cnf /etc/my.cnf

  rpm包安裝完後自動將MySQL安裝成系統服務,所以可以使用下面命令啟動、停止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.