Linux Cenos7卸载mariadb安装mysql教程

1.卸载mariadb
yum remove mariadb -y

2.查找mariadb包
rpm -qa | grep mariadb
会找到 mariadb-libs-5.5.60-1.el7_5.x86_64 也删除:
yum remove mariadb-libs-5.5.60-1.el7_5.x86_64 -y

3.删除遗留文件
rm -rf /var/lib/mysql/

下载mysql:
1.下载rpm包
wget http://dev.mysql.com/get/mysql57-community-release-el6-7.noarch.rpm
    
2.安装rpm
rpm -ivh mysql57-community-release-el6-7.noarch.rpm

vim /etc/yum.repos.d/mysql-community.repo

[mysql-connectors-community]
name=MySQL Connectors Community
baseurl=http://repo.mysql.com/yum/mysql-connectors-community/el/6/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

[mysql-tools-community]
name=MySQL Tools Community
baseurl=http://repo.mysql.com/yum/mysql-tools-community/el/6/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

# Enable to use MySQL 5.5
[mysql55-community]
name=MySQL 5.5 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.5-community/el/6/$basearch/
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

# Enable to use MySQL 5.6
[mysql56-community]
name=MySQL 5.6 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.6-community/el/6/$basearch/
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

用mysql5.7,将baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/6/$basearch/改为baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/7/$basearch/

将gpgcheck=1改为gpgcheck=0

[mysql57-community]
name=MySQL 5.7 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/7/$basearch/
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

3.yum安装
yum install -y mysql-community-client

安装依赖文件net-tools
yum install -y net-tools

将我发的mysql-community-server的rpm包发送到虚拟机。  mysql-community-server
rpm -ivh mysql-community-server-5.7.26-1.el7.x86_64.rpm 安装
     
4.启动服务
systemctl start mysqld
systemctl enable mysqld
    
5.查看临时密码 最后写是临时密码
    cat /var/log/mysqld.log | grep "temporary password"
    如果没有显示出密码,可以删除/var/lib/mysql,然后重新启动服务
    
    注意:然后通过 mysql -u root -p 回车, 进入后将临时密码粘贴进去,回车就进去了。
6.修改密码

设置密码安全度:

set global validate_password_policy=LOW; 
set global validate_password_length=4;
    alter user 'root'@'localhost' identified by '123456你自己得mysql密码';

    
7.打开远程连接
    update mysql.user set host='%' where user='root';
    
8.刷新授权
    flush privileges;

9.重启服务
    service mysqld restart
    
10.关闭防火墙
    自己查看
11.修改编码
    vim /etc/my.cnf
    在[mysqld]下添加:
        character-set-server=utf8
    重启服务

发布了11 篇原创文章 · 获赞 3 · 访问量 1385

猜你喜欢

转载自blog.csdn.net/weixin_38620636/article/details/90600696