Linux RPM 方式安装 MySQL在 hadoop02机器上

1、 安装新版mysql前,需将系统自带的mariadb-lib卸载

[root@hadoop02 ~]# rpm -qa|grep mariadb     #查询系统自带得mariadb-libmariadb-libs-5.5.68-1.el7.x86_64[root@hadoop02 ~]# rpm -e --nodeps mariadb-libs-5.5.68-1.el7.x86_64    #卸载系统自带得mariadb-lib[root@hadoop02 ~]# rpm -qa|grep mariadb     #检查系统自带得mariadb-lib是否已卸载

2. 官网下载5.7版本:https://dev.mysql.com/downloads/mysql/

3.可以使用xftp上传到hadoop02机器得/opt/mysql目录下

4. 解压安装包并

[root@hadoop02 mysql]# tar -xvf mysql-5.7.32-1.el7.x86_64.rpm-bundle.tar
mysql-community-client-5.7.32-1.el7.x86_64.rpm
mysql-community-common-5.7.32-1.el7.x86_64.rpm
mysql-community-devel-5.7.32-1.el7.x86_64.rpm
mysql-community-embedded-5.7.32-1.el7.x86_64.rpm
mysql-community-embedded-compat-5.7.32-1.el7.x86_64.rpm
mysql-community-embedded-devel-5.7.32-1.el7.x86_64.rpm
mysql-community-libs-5.7.32-1.el7.x86_64.rpm
mysql-community-libs-compat-5.7.32-1.el7.x86_64.rpm
mysql-community-server-5.7.32-1.el7.x86_64.rpm
mysql-community-test-5.7.32-1.el7.x86_64.rpm
[root@hadoop02 mysql]# ll
总用量 1060072
-rw-r--r-- 1 root root 542750720 12月 15 14:21 mysql-5.7.32-1.el7.x86_64.rpm-bundle.tar
-rw-r--r-- 1 7155 31415 26460548 9月 25 12:48 mysql-community-client-5.7.32-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415 314936 9月 25 12:48 mysql-community-common-5.7.32-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415 3918236 9月 25 12:48 mysql-community-devel-5.7.32-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415 47479624 9月 25 12:48 mysql-community-embedded-5.7.32-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415 23263144 9月 25 12:48 mysql-community-embedded-compat-5.7.32-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415 130933732 9月 25 12:48 mysql-community-embedded-devel-5.7.32-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415 2457204 9月 25 12:48 mysql-community-libs-5.7.32-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415 1260336 9月 25 12:48 mysql-community-libs-compat-5.7.32-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415 181712536 9月 25 12:49 mysql-community-server-5.7.32-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415 124941892 9月 25 12:49 mysql-community-test-5.7.32-1.el7.x86_64.rpm

为了避免出现权限问题,给mysql解压文件所在目录赋予最大权限

[root@hadoop02 opt]# chmod -R 777 mysql/
[root@hadoop02 opt]# ll
总用量 4
drwxrwxrwx 2 root root 4096 12月 15 14:23 mysql
drwxr-xr-x. 2 root root 6 10月 31 2018 rh

严格按照顺序安装:mysql-community-common-5.7.29-1.el7.x86_64.rpm、mysql-community-libs-5.7.29-1.el7.x86_64.rpm、mysql-community-client-5.7.29-1.el7.x86_64.rpm、mysql-community-server-5.7.29-1.el7.x86_64.rpm这四个包

rpm -ivh mysql-community-common-5.7.32-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.32-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-5.7.32-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-5.7.32-1.el7.x86_64.rpm --nodeps --force

5. 配置数据库

vim /etc/my.cnf

添加这三行

skip-grant-tables:跳过登录验证

character_set_server=utf8:设置默认字符集UTF-8

init_connect='SET NAMES utf8':设置默认字符集UTF-8

6 . 启动mysql服务

[root@hadoop02 mysql]# systemctl start mysqld.service  #设置开机启动
[root@hadoop02 mysql]# mysql    #启动mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.32 MySQL Community Server (GPL)

Copyright (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>

7. 设置密码和开启远程登录

设置一个简单的密码

mysql> update mysql.user set authentication_string=password('123456') where user='root';
Query OK, 1 row affected, 1 warning (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 1

mysql> flush privileges;  #立即生效
Query OK, 0 rows affected (0.01 sec)

退出mysql并停止mysql服务

mysql> quit;
Bye
[root@hadoop02 mysql]# systemctl stop mysqld.service

编辑/etc/my.cnf配置文件将:skip-grant-tables这一行注释掉 ,并重启mysql服务

[root@hadoop02 mysql]# vim /etc/my.cnf
[root@hadoop02 mysql]# systemctl start mysqld.service

再次登录mysql

[root@hadoop02 mysql]# mysql -uroot -p123456

重新重设密码

ALTER USER USER() IDENTIFIED BY '123456';

如果出现如下错误:

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements

是密码的复杂度不符合默认规定,查看密码得设置策略

mysql> SHOW VARIABLES LIKE 'validate_password%';
+--------------------------------------+-------+
| Variable_name | Value |
+--------------------------------------+-------+
| validate_password_check_user_name | OFF |      
| validate_password_dictionary_file | |       #指定密码验证的文件路径
| validate_password_length | 6 |              #固定密码的总长度;
| validate_password_mixed_case_count | 1 |    # 整个密码中至少要包含大/小写字母的总个数
| validate_password_number_count | 1 |        #整个密码中至少要包含阿拉伯数字的个数
| validate_password_policy | LOW |            #指定密码的强度验证等级,默认为 MEDIUM
| validate_password_special_char_count | 1 |
+--------------------------------------+-------+

设置密码的验证强度等级,设置 validate_password_policy 的全局参数为 LOW

set global validate_password_policy=LOW;  #只验证密码得长度
set global validate_password_length=6;   #密码验证得长度修改成功

开启mysql远程访问

grant all privileges on *.* to 'root'@'%' identified by '123123' with grant option;

by后面的就是远程登录密码,远程登录密码可以和用户密码不一样

最新文章

  1. Autodesk hackathon 技术参考资料
  2. LeetCode题解-----First Missing Positive
  3. q和blockquote标签的区别
  4. 5月4日课堂内容:for循环的穷举、迭代
  5. 数据结构典型算法的VC实现(袁辉勇)
  6. [Locked] Closest Binary Search Tree Value & Closest Binary Search Tree Value II
  7. Webpack 基本环境搭建
  8. zxing生成和解析二维码
  9. 正整数从1到N,输出按照字典序排序的前K个数
  10. deb包+软件图标+添加到系统菜单+举例安装卸载
  11. Android版本和API Level的对应关系
  12. Hibernate3提供的属性的延迟加载功能
  13. 保存Druid的监控记录
  14. Linux操作系统上要慎用的6个命令及防范方法
  15. GXOI/GZOI2019题解
  16. flask 第七章 简陋版智能玩具 +MongoDB初识和基本操作
  17. springboot2.0集成shiro出现ShiroDialect报错找不到AbstractTextChildModifierAttrPr
  18. go标准库的学习-mime
  19. CentOS开放端口号
  20. 使用自签名SSL证书配置HTTPS,解决浏览器提示不安全警告

热门文章

  1. PostGIS之维数扩展的九交模型
  2. 红米手机LineageOS Root(实操)
  3. 硬件IIC的7位从机地址查询方式读写参考代码
  4. centos 7 删除乱码文件
  5. centos7 elasticsearch集群安装
  6. jmeter接口自动化-读取CSV文件执行测试用例
  7. Unity中UGUI图片跟随文本自适应方法
  8. 教你如何自己搭环境部署华为FusionCompute虚拟化系统
  9. aqueduct “Uncaught error Bad state: No element" 或者 "NoSuchMethodError: The getter 'location' was called on null.”
  10. 如何添加Eclipse项目到SVN资源库