MySQL的 安裝、配置、卸載

用戶7353950 2022-06-23 17:31:38 阅读数:160

mysql配置

Mysql的安裝配置(基於Centos7)

安裝mysql數據庫

[[email protected] ~]# wget https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm
[[email protected] ~]# yum -y install mysql57-community-release-el7-9.noarch.rpm
[[email protected] ~]# cd /etc/yum.repos.d/
[[email protected] ~]# yum -y install mysql-server

啟動數據庫

[[email protected] ~]# systemctil start mysqld

查詢初始化數據庫密碼

[[email protected] ~]# grep 'passowrd' /var/log/mysql.log
--顯示的 [email protected]: ***就是初始化的數據庫登錄密碼

登錄到數據庫

[[email protected] ~]# mysql -uroot -p
[[email protected] ~]# password:

設置密碼

mysql> set password for 用戶名@localhost = password('新密碼');

查看密碼設置

mysql> show variables like 'validate_password%';

修改密碼等級為低

mysql> set global validate_password_policy=LOW;

改密碼長度最小為6比特

mysql> set global validate_password_length=6;

設置數據庫新密碼

mysql> set password for 'root'@'localhost' = password('bigdata');

開啟遠程訪問數據庫

mysql> grant all privileges on *.* to 'root'@'%' identified by 'bigdata' with grant option;mysql> flush privileges;

Mysql的完全卸載(基於Centos7)

查詢與mysql有關的rpm包

[[email protected] ~]# rpm -qa |grep -i mysql
mysql57-community-release-el7-9.noarch
mysql-community-client-5.7.32-1.el7.x86_64
mysql-community-libs-5.7.32-1.el7.x86_64
mysql-community-libs-compat-5.7.32-1.el7.x86_64
mysql-community-common-5.7.32-1.el7.x86_64
mysql-community-server-5.7.32-1.el7.x86_64

使用yum remove命令卸載這些包

[[email protected] ~]# yum remove mysql57-community-release-el7-9.noarch
[[email protected] ~]# yum remove mysql-community-client-5.7.32-1.el7.x86_64
[[email protected] ~]# yum remove mysql-community-libs-5.7.32-1.el7.x86_64
[[email protected] ~]# yum remove mysql-community-libs-compat-5.7.32-1.el7.x86_64
[[email protected] ~]# yum remove mysql-community-common-5.7.32-1.el7.x86_64
[[email protected] ~]# yum remove mysql-community-server-5.7.32-1.el7.x86_64

查找mysql的相關目錄殘留並删除

[[email protected] ~]# find / -name mysql
/etc/selinux/targeted/active/modules/100/mysql
/var/lib/mysql
/var/lib/mysql/mysql
/usr/share/mysql

删除殘留

[[email protected] ~]# rm -rf /etc/selinux/targeted/active/modules/100/mysql
[[email protected] ~]# rm -rf /var/lib/mysql
[[email protected] ~]# rm -rf /var/lib/mysql/mysql
[[email protected] ~]# rm -rf /usr/share/mysql

删除/var/log/mysqld.log

[[email protected] ~]# rm -rf /var/log/mysqld.log
--如果不删除這個文件,會導致新安裝的mysql無法生存新密碼,造成無法登陸mysql
版权声明:本文为[用戶7353950]所创,转载请带上原文链接,感谢。 https://gsmany.com/2022/174/202206231642464911.html