一.安装
1.下载mysql压缩包
1
2
3
4 复制> [root@zhou etc]# wget http://repo.mysql.com/mysql80-community-release-el7.rpm
> 版本可自行选择,后面的解压一致就行
>
2.解压缩
1
2
3 复制> rpm -Uvh mysql80-community-release-el7.rpm
>
3.安装MySQL服务端
1
2
3 复制> yum install -y mysql-community-server
>
4.更改配置文件(为后续的导入数据库准备)
[root@zhou ~]# vi /etc/my.cnf
在my.cnf中的[mysqld]下面(位置不能错)加上
lower_case_table_names=1
这句(1表示不区分大小写,0区分大小写),保存重新启动mysql。
5.启动mysql
1
2
3
4 复制> service mysqld start
> systemctl start mysqld.service
>
6.检查mysql 的运行状态(可省略)
1
2
3
4
5 复制> service mysqld status
> systemctl status mysqld.service
> 上面两个命令是一个意思
>
7.获取临时密码
Mysql5.7默认安装之后root是有密码的。
[root@zhou ~]# grep ‘temporary password’ /var/log/mysqld.log #注意单引号是英文的
2020-11-14T08:08:45.867775Z 1 [Note] A temporary password is generated for root@localhost: urlunfhoa1!M###这里临时密码是urlunfhoa1!M
8.登陆MySQL并修改密码
[root@zhou ~]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.32Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.
mysql> ALTER USER ‘root‘@’localhost’ IDENTIFIED BY ‘000000’;
注:密码太简单会报错
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
执行以下语句即可
1
2
3
4 复制> > set global validate_password.policy=0;
> > set global validate_password.length=4;
> >
ALTER USER 'root'@'localhost' IDENTIFIED BY '000000';
二.卸载
1.关闭MySQL
service mysqld stop
2.查看安装的mysql
rpm -qa|grep -i mysql
3.卸载安装的mysql
rpm -ev mysql-community-client-8.0.11-1.el7.x86_64 –nodeps
rpm -ev mysql-community-common-8.0.11-1.el7.x86_64 –nodeps
4.删除mysql相关目录
5.删除my.cnf
rm -rf /etc/my.cnf
6.检查卸载情况
rpm -qa|grep -i mysql 显示为空,卸载完毕。