过程中一路选y
一.
vi /etc/selinux/config ,i进入编辑模式,设置SELINUX=disabled,esc退出编辑模式,:wq保存退出(:w保存 :q退出)
reboot命令重新启动centOS
二.
替换yum源https://www.cnblogs.com/zzsdream/p/7405083.html
CentOS 7
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo或者
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
更新缓存
yum clean all
yum makecache
三. MySQL官方地址 MySQL Yum仓库的RPM安装包
通过wget方式获取yum包
wget http://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm
四. 安装MySQL RPM安装包
命令:
yum localinstall mysql80-community-release-el7-1.noarch.rpm
看到安装MySQL8.0安装完成后可到/etc/yum.repos.d/目录下看到:
mysql-community.repo mysql-community-source.repo
两个文件,说明MySQL Yum仓库添加成功。
五. 安装MySQL
[root@*******0x2dru8ftg3uz yum.repos.d]# yum install mysql-community-server
完成之后数据库会有一个初始密码,可通过一下命令查看:
[root@*******2dru8ftg3uzlog]# sudo grep'temporary password'/var/log/mysqld.log
至此,MySQL8.0 安装完成,下面进行启动配置。
六.启动MySQL8.0
##启动MySQL服务 service mysqld start
##查看MySQL进程 ps -ef |grep mysql
##停止MySQL服务:service mysqld stop
七.进行一些必要的配置
1、修改初始密码
##查看默认密码
shell> sudo grep 'temporary password' /var/log/mysqld.log
##使用默认密码登陆(使用该方法登陆数据库)
shell> mysql -uroot -p
#MySQL8.0修改密码需要有大小写字母、数字、特殊字符组合
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'Lijiantao1998.';
#默认情况下密码策略要求密码至少包含一个大写字母、一个小写字母、一个数字和一个特殊字符,并且总密码长度至少为8个字符。
否则回报出:ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
validate_password is installed by default. The default password policy implemented by validate_password requires that passwords contain at least one upper case letter, one lower case letter, one digit, and one special character, and that the total password length is at least 8 characters.
2、外网/客户端访问问题
客户访问报错:ERROR 1130: Host '192.168.1.3' is not allowed to connect to this MySQL
解决方案:
服务端登陆MySQL,修改user表登陆用户的host。
shell>
mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> show tables;
+---------------------------+
| Tables_in_mysql |
+---------------------------+
| columns_priv |
此处省略n个表
| time_zone_transition |
| time_zone_transition_type |
| user |
+---------------------------+
33 rows in set (0.00 sec)
mysql> update user set host='%' where user='root';
Query OK, 1 row affected (0.07 sec)
Rows matched: 1 Changed: 1 Warnings: 0
客户端建立连接报错:2059 - authentication plugin 'caching_sha2_password' ...
解决方案:
执行sql:
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'Lijiantao1998.';
另外阿里云的防火墙默认端口是不开放的,需要在控制台进行设置,不打开端口外网也是访问不到的。
在防火墙上添加mysql的3306端口即可
终于大功告成。
原文链接(https://blog.csdn.net/qq_32672633/article/details/80325470)