天天看點

yum 安裝解除安裝mysql

以前做過yum安裝解除安裝mysql的筆記,現在整理到網上,希望對需要的朋友有所幫助

1.下載下傳YUM庫

 wget http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm

 或wget --no-check-certificate http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm

2.安裝YUM庫

yum localinstall -y mysql57-community-release-el7-10.noarch.rpm

3.安裝資料庫

 yum install -y mysql-community-server    

4.啟動MySQL服務

systemctl start mysqld.service

5.查找mysql安裝時的臨時密碼

 grep 'password' /var/log/mysqld.log |head -n 1

mysql -uroot -p回車

輸入密碼

6.修改密碼,解決密碼安全問題:

如何解決ERROR 1819 (HY000): Your password does not satisfy the current policy requirements錯誤?

解決:必須修改兩個全局參數

set global validate_password_policy=0; 

再修改密碼的長度:set global validate_password_length=1;

修改密碼:SET PASSWORD = PASSWORD('root'); 

7.添加遠端登入使用者

use mysql;

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;

設定防火牆:

1)centos6

vi /etc/sysconfig/iptables

在-A RH-Firewall-1-INPUT -j REJECT –reject-with icmp-host-prohibited之前,添加

-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT

重新開機防火牆

service iptables restart

2)centos7

啟動:# systemctl start  firewalld

檢視狀态:# systemctl status firewalld 或者 firewall-cmd --state

停止:# systemctl stop firewalld

禁用:# systemctl disable firewalld

8.設定字元編碼和區分大小寫

SHOW VARIABLES LIKE '%char%';

修改mysql配置檔案:vi /etc/my.cnf

[mysqld]

character-set-server=utf8

collation-server=utf8_general_ci

#區分大小寫——-0:區分;1:不區分

lower_case_table_names=1

[client]

default-character-set=utf8

9.設定開機自啟:

設定開機自動啟動

# chkconfig mysqld on  或者  systemctl enable mysqld

# chkconfig --list | grep mysql

更新mysql-server

yum update mysql-server

mysql安裝出現的錯誤:

-bash: mysql: command not found

解決:

# cd /usr/local/bin

# ln -fs /mysql安裝路徑/bin/mysql mysql

1、yum remove mysql mysql-server mysql-libs compat-mysql51

2、rm -rf /var/lib/mysql

3、rm /etc/my.cnf

檢視是否還有mysql軟體:

rpm -qa|grep mysql

如果存在的話,繼續删除即可。

a)檢視系統中是否以rpm包安裝的mysql:

[[email protected] opt]# rpm -qa | grep -i mysql

MySQL-server-5.6.17-1.el6.i686

MySQL-client-5.6.17-1.el6.i686

b)解除安裝mysql

[[email protected] local]# rpm -e MySQL-server-5.6.17-1.el6.i686

[[email protected] local]# rpm -e MySQL-client-5.6.17-1.el6.i686

c)删除mysql服務

[[email protected] local]# chkconfig --list | grep -i mysql

[[email protected] local]# chkconfig --del mysql

d)删除分散mysql檔案夾

[[email protected] local]# whereis mysql 或者 find / -name mysql

mysql: /usr/lib/mysql /usr/share/mysql

清空相關mysql的所有目錄以及檔案

rm -rf /usr/lib/mysql

rm -rf /usr/share/mysql

rm -rf /usr/my.cnf

繼續閱讀