yum安装mysql8+踩坑记录
当前服务器和mysql基本信息
- 标准型S4 centOS7.5 64位
- 1 核 2 GB 1 Mbps
- 腾讯云
- mysql Ver 8.0.18 for Linux on x86_64 (MySQL Community Server - GPL)
- windows下载: https://dev.mysql.com/downloads/repo/yum/ (25kb左右)
- Linux命令行(对应的下载地址):
[root@VM_0_11_centos rpms]# wget -i -c https://repo.mysql.com//mysql80-community-release-el7-3.noarch.rpm
- 上传MySql repository
- xftp 等可视化上传工具上传
- 命令行 rz 上传,rz安装和使用方法 https://www.cnblogs.com/nbf-156cwl/p/8641165.html
[root@VM_0_11_centos rpms]# rz
- xftp 等可视化上传工具上传
- 安装MySql repository,一路yes就行了
[root@VM_0_11_centos rpms]# yum -y install mysql57-community-release-el7-10.noarch.rpm
- 【yum安装mysql8+踩坑记录】更新yum仓库,一路yes就行了
[root@VM_0_11_centos rpms]# yum update
- 安装mysql,一路yes就行了,根据网速决定你等待的时间,大小大概在400MB+
[root@VM_0_11_centos rpms]# yum -y install mysql-community-server
- 启动MySql服务
[root@VM_0_11_centos rpms]# systemctl startmysqld.service
- 检查一下服务状态是否是:running
[root@VM_0_11_centos rpms]# systemctl status mysqld.service ● mysqld.service - MySQL Server Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled) Active: active (running) since Wed 2019-11-06 10:52:55 CST; 11min ago Docs: man:mysqld(8) http://dev.mysql.com/doc/refman/en/using-systemd.html Process: 946 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS) Main PID: 3087 (mysqld) Status: "Server is operational" CGroup: /system.slice/mysqld.service └─3087 /usr/sbin/mysqldNov 06 10:52:38 VM_0_11_centos systemd[1]: Starting MySQL Server... Nov 06 10:52:55 VM_0_11_centos systemd[1]: Started MySQL Server.
- 找到安装的初始密码,密码在最后面:Khp?geIig8.&
[root@VM_0_11_centos rpms]# grep "password" /var/log/mysqld.log 2019-11-06T02:52:46.432088Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: Khp?geIig8.&
- 命令登陆mysql
[root@VM_0_11_centos rpms]# mysql -uroot -p Enter password: 这里输入刚才的初始密码,不会回显的,注意别输错了
以前的策略对应的修改命令:
```mysql
mysql> set global validate_password_policy=0;
Query OK, 0 rows affected (0.00 sec)mysql> set global validate_password_length=1;
Query OK, 0 rows affected (0.00 sec)
```
8+的策略
```mysql
mysql> set global validate_password.policy=0;
Query OK, 0 rows affected (0.00 sec)mysql> set global validate_password.length=1;
Query OK, 0 rows affected (0.00 sec)
```
新老策略对比
```
老版本的密码策略变量:
validate_password_policy 用于控制validate_password的验证策略 0->low 1->MEDIUM 2->strong。
validate_password_length密码长度的最小值(这个值最小要是4)。
validate_password_number_count 密码中数字的最小个数。
validate_password_mixed_case_count大小写的最小个数。
validate_password_special_char_count 特殊字符的最小个数。
validate_password_dictionary_file 字典文件
8.0后要注意密码策略变量变化
validate_password.check_user_name ON
validate_password.dictionary_file
validate_password.length
validate_password.mixed_case_count
validate_password.number_count
validate_password.policy
validate_password.special_char_count如:
validate_password_policy 变为 validate_password.policy.
所以
set global validate_password_policy=0;
变为
set global validate_password.policy=0;
密码最小长度(6):
set global validate_password_length=6;
变为
set global validate_password.length=6
```
修改密码
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '你的新密码';
Query OK, 0 rows affected (0.00 sec)
4、开启远程访问权限
查看当前访问权限
mysql> select user, host from user;
ERROR 1046 (3D000): No database selectedmysql> show databases;
+--------------------+
| Database|
+--------------------+
| information_schema |
| mysql|
| performance_schema |
| sys|
+--------------------+
4 rows in set (0.00 sec)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 -ADatabase changed
mysql> select user,host from user;
+------------------+-----------+
| user| host|
+------------------+-----------+
| mysql.infoschema | localhost |
| mysql.session| localhost |
| mysql.sys| localhost |
| root| localhost |
+------------------+-----------+
4 rows in set (0.00 sec)
修改远程访问权限,修改完后注意要刷新才能生效,然后就可以使用navicat之类的可视化工具远程访问了
mysql> update user set host = '%' where user = 'root';
Query OK, 1 row affected (0.01 sec)
Rows matched: 1Changed: 1Warnings: 0mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
推荐阅读
- Mac安装Chromedriver
- MongoDB,Wondows下免安装版|MongoDB,Wondows下免安装版 (简化版操作)
- MAC安装Mongo
- 【Hadoop踩雷】Mac下安装Hadoop3以及Java版本问题
- react|react 安装
- VueX--VUE核心插件
- python-安装sublime遇到异常
- typeScript入门基础介绍
- 监控nginx
- 使用homeBrew|使用homeBrew 安装Goland