centos mysql 安装以及卸载重新安装

1. 如果已经有了mysql,卸载办法

  1. 查看是否还有mysql软件
rpm -qa | grep mysql
# 卸载mysql相关依赖
yum remove  mysql mysql-server mysql-libs mysql-server;
  1. 将找到的相关东西delete掉
find / -name mysql
rm /etc/my.cnf
rm -rf /usr/lib/mysql
rm -rf /usr/share/mysql
通过以上几步,mysql应该已经完全卸载干净了.

2. 安装mysql

  1. 配置YUM源, 在MySQL官网中下载YUM源rpm安装包:http://dev.mysql.com/downloads/repo/yum/
# 下载mysql源安装包
shell> wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
# 安装mysql源
shell> yum localinstall mysql57-community-release-el7-8.noarch.rpm
# 检查mysql源是否安装成功
yum repolist enabled | grep "mysql.*-community.*"
  1. 安装
yum install -y mysql mysql-server mysql-libs mysql-server
  1. 启动
systemctl start  mysqld.service
systemctl status mysqld.service
# 配置文件
vim /etc/my.cnf
# mysqld下增加如下内容
skip-grant-tables
character_set_server=utf8
init_connect='SET NAMES utf8'


# 重启mysql服务
systemctl start  mysqld.service
  1. 配置mysql
# 设置一个密码
update mysql.user set authentication_string=password('123abcAbc.') where user='root';

flush privileges;
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123abcAbc.' WITH GRANT OPTION
flush privileges;
  1. 编辑配置文件取消掉跳过登陆,重启mysql服务,链接测试

你可能感兴趣的:(mysql)