標籤:details move bin csdn base word html boa 清理
轉: http://blog.csdn.net/skylinethj/article/details/38524629 ubuntu12.04 安裝和卸載mysql
關於授權的文章請看 http://blog.csdn.net/id19870510/article/details/8434421
===================================================================
1:登入系統,安裝之前最好先,
[html] view plaincopy
- apt-get update
否則會出現找不到安裝檔案得錯誤提示
2:安裝MySQL伺服器以及用戶端
[html] view plaincopy
- apt-get install mysql-server mysql-client
安裝得過程中會提示你輸入root得密碼。
3:安裝完成以後預設mysql不能遠端存取
[html] view plaincopy
- vi /etc/mysql/my.cnf
[html] view plaincopy
- 注釋掉 bind-address = 127.0.0.1
4:用root登入到mysql,然後用grant命令添加使用者,如:
[html] view plaincopy
- mysql> grant all privileges on 需要訪問的db.* to [email protected]‘%‘ identified by ‘password’; 為了安全,代碼裡面別用root
第一種:
增加一個使用者test1密碼為abc,讓他可以在任何主機上登入,並對所有資料庫有查詢、插入、修改、刪除的許可權。首先用以root使用者連入MYSQL,然後鍵入以下命令:
mysql>grant select,insert,update,delete on *.* to [email protected]‘%‘ identified by ‘abc‘;
或
mysql>grant all privileges on *.* to [email protected]‘%‘ identified by ‘abc‘;
但增加的使用者是十分危險的,你想如某個人知道test1的密碼,那麼他就可以在internet上的任何一台電腦上登入你的mysql資料庫並對你的資料可以為所欲為了,解決辦法見例第二種:
第一種:增加一個使用者test2密碼為abc,讓他只可以在localhost上登入,並可以對資料庫mydb進行查詢、插入、修改、刪除的操作(localhost指本地主機,即MYSQL資料庫所在的那台主機),這樣使用者即使用知道test2的密碼,他也無法從internet上直接存取數
mysql> grant select,insert,update,delete on book.* to [email protected] Identified by ’abc‘;
如果你不想test2有密碼,可以再打一個命令將密碼消掉。
mysql> grant select,insert,update,delete on book.* to [email protected] Identified by ’‘;
5:重啟mysql
[html] view plaincopy
- /etc/init.d/mysql restart
[html] view plaincopy
- 卸載 mysql
- sudo apt-get autoremove –purge mysql-server-5.5 //具體按TAB鍵提示
- sudo apt-get remove mysql-server
- sudo apt-get autoremove mysql-server
- sudo apt-get remove mysql-common //這個很重要
第二步:清理殘留資料
1 dpkg -l |grep ^rc|awk ‘{print $2}‘ |sudo xargs dpkg -P
查看是否安裝成功
tcp 0 0 localhost.localdomain:mysql *:* LISTEN -
如果伺服器不能正常運行,您可以通過下列命令啟動它:
1 sudo /etc/init.d/mysql restart
第四步:組態管理員密碼
進入mysql
1 $mysql -u root -p 管理員密碼
配置 MySQL 的管理員密碼:
1 sudo mysqladmin -u root password newpassword
ubuntu12.04 安裝和卸載mysql