安裝解除安裝mysql
1,安裝
sudo apt-get install mysql-server
sudo apt-get install mysql-client
sudo apt-get install php5-mysql(用于連接配接php和mysql)
檢視mysql是否運作
ps aux | grep mysql
啟動指令
/etc/init.d/mysql start
2.删除mysql
按順序執行以下指令
sudo apt-get autoremove --purge mysql-server-5.0
sudo apt-get remove mysql-server
sudo apt-get autoremove mysql-server
sudo apt-get remove mysql-common
清理殘留資料
dpkg -l |grep ^rc|awk '{print $2}' |sudo xargs dpkg -P
:wink: :wink: :wink: :wink: :wink: :wink: :wink: :wink: :wink: :wink:
配置遠端連接配接:
第一步:
1,mysql> use mysql;
2,mysql> update user set host = ’%’ where user = ’root’;
3,mysql> select host,user,password from user;
4,在需要連接配接的伺服器端檢視使用者權限:
show grants;
出現 如下
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY PASSWORD '*EA5FD23FAEE21132435461B733F64981454FD4AF' WITH GRANT OPTION
标示授權成功
授權使用者能進行遠端連接配接
grant all privileges on *.* to root@"%" identified by "password" with grant option;(不需要執行,mysql已經幫你自動執行當修改為%的時候)
flush privileges;
第一行指令解釋如下,*.*:第一個*代表資料庫名;第二個*代表表名。這裡的意思是所有資料庫裡的所有表都授權給使用者。root:授予root賬号。“%”:表示授權的使用者IP可以指定,這裡代表任意的IP位址都能通路MySQL資料庫。“password”:配置設定賬号對應的密碼,這裡密碼自己替換成你的mysql root帳号密碼。
第二行指令是重新整理權限資訊,也即是讓我們所作的設定馬上生效。
第二步
vim /etc/mysql/my.cnf找到bind-address = 127.0.0.1
注釋掉這行,如:#bind-address = 127.0.0.1
或者改為: bind-address = 0.0.0.0
允許任意IP通路;
或者自己指定一個IP位址。
再最後加上下面兩句:
skip-external-locking
skip-name-resolve
重新開機 MySQL:sudo /etc/init.d/mysql restart