二进制方式安装mysql
下载官方打包好的rpm的集合
https://downloads.mysql.com/archives/get/file/mysql-5.7.20-1.el7.x86_64.rpm-bundle.tar
[root@xuegod63 opt]# tar xf mysql-5.7.20-1.el7.x86_64.rpm-bundle.tar
解压出来,发现有很多rpm包,我们需要用到的包是:
mysql-community-common-5.7.20-1.el7.x86_64.rpm
mysql-community-libs-5.7.20-1.el7.x86_64.rpm
mysql-community-client-5.7.20-1.el7.x86_64.rpm
mysql-community-server-5.7.20-1.el7.x86_64.rpm
依次安装:
yum install mysql-community-common-5.7.20-1.el7.x86_64.rpm -y
yum install mysql-community-libs-5.7.20-1.el7.x86_64.rpm -y
yum install mysql-community-client-5.7.20-1.el7.x86_64.rpm -y
yum install mysql-community-server-5.7.20-1.el7.x86_64.rpm -y
注意安装 mysql-community-server-5.7.20-1.el7.x86_64.rpm报错
[root@b mysql-5.7.26]# yum install mysql-community-server-5.7.26-1.el6.x86_64.rp m -y
Error: Package: mysql-community-server-5.7.26-1.el6.x86_64 (/mysql-community-ser ver-5.7.26-1.el6.x86_64)
Requires: libsasl2.so.2()(64bit)
You could try using --skip-broken to work around the problem
You could try running: rpm -Va --nofiles --nodigest
[root@b mysql-5.7.26]# rpm -ivh mysql-community-server-5.7.26-1.el6.x86_64.rpm
warning: mysql-community-server-5.7.26-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
error: Failed dependencies:
libsasl2.so.2()(64bit) is needed by mysql-community-server-5.7.26-1.el6.x86_64
原因:这是由于yum安装了旧版本的GPG keys造成的 解决办法: --force --nodeps
[root@b mysql-5.7.26]# rpm -ivh mysql-community-server-5.7.26-1.el6.x86_64.rpm --force --nodeps
warning: mysql-community-server-5.7.26-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:mysql-community-server-5.7.26-1.e################################# [100%]
(注意:安装顺序不能错,否则会报错依赖包没有安装)
查看安装路径:
[root@xuegod63 opt]# rpm -ql mysql-community-server
可以看到数据库安装在/var/lib/mysql 目录下
启动服务:
[root@xuegod63 opt]# systemctl start mysqld.service
获取临时密码:
第一次通过# grep "password" /var/log/mysqld.log 命令获取MySQL的临时密码
用该密码登录到服务端后,必须马上修改密码,不然操作查询时报错误
[root@xuegod63 opt]# grep "password" /var/log/mysqld.log
2017-11-10T14:38:40.930543Z 1 [Note] A temporary password is generated for root@localhost: itBp#lFva0aY
补充注意:MySQL5.7之前的版权,初次安装MySQL,默认登陆密码是空,5.7之后的版本,默认登陆的密码为一个随机生产的字符串,存在/var/log/mysqld.log 文件里。
安全初始化操作:
[root@xuegod65 opt]# mysql_secure_installation
修改默认密码和相关的权限
MySQL5.7对密码复杂度要求比较高,刚开始设置的密码必须符合长度(默认最小长度的8),且必须含有数字,小写或大写字母,特殊字符。
这也是从安全考虑,希望使用者不要强行修改密码策略,设置简单的密码
Welcome1qazx@com
如果想设置简单密码,如下操作:
[root@localhost ~]# mysql -uroot -p' itBp#lFva0aY '
方法一:首先,修改validate_password_policy参数的值
mysql> set global validate_password_policy=0; #定义复杂度
mysql> set global validate_password_length=1; #定义长度 默认是8
方法二:在/etc/my.cnf 可关闭密码强度审计插件,重启mysql服务
validate_password=ON/OFF/FORCE/FORCE_PLUS_PERMANENT: 决定是否使用该插件(及强制/永久强制使用)。
修改密码
mysql>
set password for 'root'@'localhost'=password('123456'); 修改root账号登陆密码
Query OK, 0 rows affected, 1 warning (0.05 sec)
刷新权限表(使更改密码立即生效而不用重启mysql)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
登陆linux下的mysql5.7忘记密码
解决方法
- 第一步:打开mysql5.7的配置文件my.cnf,并在里面增加一行:skip-grant-tables 保存并退出(:wq)
[root@iz09a32x1sghz3z ~]# vi /etc/my.cnf
- 第二步:重启mysql
[root@iz09a32x1sghz3z ~]# service mysqld restart
- 第三步:登录mysql并且修改密码
用root账号登录: [root@iz09a32x1sghz3z ~]# mysql -u root
使用mysql中的mysql数据库: mysql> use mysql;
修改密码: update user set authentication_string = password("Szfore_68638") where user="root" ;
刷新数据库: flush privileges;
退出: quit;
注意:mysql5.7的user表中的password字段已经改成了authentication_string 字段了。
这时候,需要输入的命令是update user set authentication_string = password("Szfore_68638") where user="root" ;
- 第四步:打开mysql5.7的配置文件my.cnf,把刚增加这行:skip-grant-tables 删除掉 保存并退出(:wq)
Table 2.11 MySQL Installation Layout for Linux RPM Packages from the MySQL Developer Zone
Files or Resources | Location |
---|---|
Client programs and scripts | /usr/bin |
mysqld server | /usr/sbin |
Configuration file | /etc/my.cnf |
Data directory | /var/lib/mysql |
Error log file |
For RHEL, Oracle Linux, CentOS or Fedora platforms: For SLES: |
Value of secure_file_priv |
/var/lib/mysql-files |
System V init script |
For RHEL, Oracle Linux, CentOS or Fedora platforms: For SLES: |
Systemd service |
For RHEL, Oracle Linux, CentOS or Fedora platforms: For SLES: |
Pid file | /var/run/mysql/mysqld.pid |
Socket | /var/lib/mysql/mysql.sock |
Keyring directory | /var/lib/mysql-keyring |
Unix manual pages | /usr/share/man |
Include (header) files | /usr/include/mysql |
Libraries | /usr/lib/mysql |
Miscellaneous support files (for example, error messages, and character set files) | /usr/share/mysql |
RHEL, Oracle Linux, CentOS, and Fedora systems:
shell> sudo grep 'temporary password' /var/log/mysqld.log
The next step is to log in with the generated, temporary password and set a custom password for the superuser account:
shell> mysql -uroot -p
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';
二进制方式安装mysql的更多相关文章
- Linux下通用二进制方式安装MySQL
1.下载glibc版本的MySQL: https://downloads.mysql.com/archives/community/ 2.查看mysql用户和mysql组是否存在(用户和组的信息存在/ ...
- MAC使用二进制方式安装Mysql 5.7
一.参考文档: 二.基础环境: 系统:Centos7.4 mysql版本:percona mysql 5.7 三.部署mysql 1.初始化 mysqld --initialize --explici ...
- 2-14 MySQL初步认识,及CentOS6.8环境,源码方式安装MySQL
什么是数据库: 存放数据的仓库RDBMS-->(Relational Database Management System) 关系型数据库管理系统DBMS--->(Database Man ...
- CentOS 6 自定义单实例 二进制方式 安装mariadb-5.5.59
系统平台: CentOS release 6.9 (Final) 内核 2.6.32-696.el6.x86_64 1.去官网下载适合的二进制包 http://mariadb.org/ mariadb ...
- 二进制包安装MySQL数据库
1.1二进制包安装MySQL数据库 1.1.1 安装前准备(规范) [root@Mysql_server ~]# mkdir -p /home/zhurui/tools ##创建指定工具包存放路径 [ ...
- CentOS 6.5 RPM包方式安装 Mysql 5.6
1. 下载MySQL 5.6 下载页面:http://dev.mysql.com/downloads/mysql/此处选择“Red Hat Enterprise Linux 6 / Oracle Li ...
- 在centos使用rpm包的方式安装mysql,以及更改root密码
在centos使用rpm包的方式安装mysql,对于centos官方实际推荐使用yum进行安装,下载安装的方式主要用于内网服务器不能连接外网yum源的情况. 下载包 首先根据centos版本在mysq ...
- CentOS7下通过rpm方式安装MySQL及插入中文问题解决 [原创]
一 CentOS下通过rpm方式安装MySQL CentOS版本:CentOS-7 MySQL版本:MySQL-5.6.22 在网上搜了一下,Linux下安装MYSQL有三种方式: 1) 通过yum命 ...
- CentOS 6.5通过yum的方式安装MySql
一.mysql简介 说到数据库,我们大多想到的是关系型数据库,比如mysql.oracle.sqlserver等等,这些数据库软件在windows上安装都非常的方便,在Linux上如果要安装数据库,咱 ...
随机推荐
- luogu P5342 [TJOI2019]甲苯先生的线段树
传送门 你个好好的省选怎么可以出CF原题啊,你们这个题害人不浅啊,这样子出题像极了cxk,说到cxk,我又想起了他是NBA形象大使,跟我是西游文化大使一样一样的,今年下半年... 别说了,jinsai ...
- idea启动,mysql连接超时错误
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received ...
- Smoke Testing
[Smoke Testing 释义] Smoke Testing 的概念最早源于制造业,用于测试管道.测试时,用鼓风机往管道里灌烟,看管壁外面是否有烟冒出来,以便检验管道是否有缝隙.这一测试显然比较初 ...
- 交叉工具链和makefile
交叉工具链: arm-linux-gcc:交叉编译器 arm-linux-ld:交叉连接器 arm-linux-readelf:交叉ELF文件工具 arm-linux-objdump:交叉反汇编器 a ...
- jquery 未来元素事件示例 on() delegate() live()
jquery 1.7版后建议使用on() $(document).on("click","#green",function(){$(this).after('& ...
- Java并发编程实战 第6章 任务并行 第7章 取消与关闭
ExecutorCompletionService CompletionService用来接收一个Executor的执行结果,将已经完成任务,放置在可使用 take 访问的队列上. 大概用法: Exe ...
- IDEA部署Spring-boot到Docker容器
一.准备工作 idea安装Docker插件 centos7系统安装docker 二.打开docker远程端口 1. 编辑docker.service文件 vim /usr/lib/systemd/sy ...
- Softmax函数与交叉熵
在Logistic regression二分类问题中,我们可以使用sigmoid函数将输入Wx+b映射到(0,1)区间中,从而得到属于某个类别的概率.将这个问题进行泛化,推广到多分类问题中,我们可以使 ...
- jquery easyui datagrid 远程加载数据----javascript法
jquery easyui有三种办法生成datagrid(数据网格),本篇专门讨论javascript借助jquey easy ui实现的方式 html部分 <main role="m ...
- 两台linux服务器相互拷贝文件的两个方法
scp是secure copy的简写,用于在Linux下进行远程拷贝文件的命令,和它类似的命令有cp,不过cp只是在本机进行拷贝不能跨服务器,而且scp传输是加密的.可能会稍微影响一下速度.当你服务器 ...