mysql 5.7 二进制安装
二进制 安装
下载并上传软件至 /server/tools
[[email protected] ~]# mkdir -p /server/tools
[[email protected] ~]# cd /server/tools/
[[email protected] /server/tools]# yum install -y lrzsz
[[email protected] /server/tools]# ls
mysql-5.7.26-linux-glibc2.12-x86_64.tar.gz
解压软件
(福利推荐:阿里云、腾讯云、华为云服务器最新限时优惠活动,云服务器1核2G仅88元/年、2核4G仅698元/3年,点击这里立即抢购>>>)
[[email protected] /server/tools]# tar xf mysql-5.7.26-linux-glibc2.12-x86_64.tar.gz
[[email protected] ~]# mkdir /application
[[email protected] /server/tools]# mv mysql-5.7.26-linux-glibc2.12-x86_64 /application/mysql
创建用户 处理原始环境
[[email protected] ~]# yum remove mariadb-libs-5.5.60-1.el7_5.x86_64 -y
[[email protected] ~]# rpm -qa |grep mariadb
[[email protected] ~]# useradd -s /sbin/nologin mysql
设置环境变量
vim /etc/profile
export PATH=/application/mysql/bin:$PATH
[[email protected] ~]# source /etc/profile
[[email protected] ~]# mysql -V
mysql Ver 14.14 Distrib 5.7.26, for linux-glibc2.12 (x86_64) using EditLine wrapper
创建数据路径并授权
添加一块新磁盘模拟数据盘
格式化并挂载磁盘
[[email protected] ~]# mkfs.xfs /dev/sdc
[[email protected] ~]# mkdir /data
[[email protected] ~]# blkid
[[email protected] ~]# vim /etc/fstab
[[email protected] ~]# UUID=”b7fde522-aa37-412a-9584-8313a673c5cc” /data xfs defaults 0 0
[[email protected] ~]# mount -a
[[email protected] ~]# df -h
授权
chown -R mysql.mysql /application/*
chown -R mysql.mysql /data
初始化数据(创建系统数据)
5.6 版本
/application/mysql/scripts/mysql_install_db
5.7 版本
正常版
[[email protected] ~]# mkdir /data/mysql/data -p
[[email protected] ~]# chown -R mysql.mysql /data
[[email protected] ~]# mysqld –initialize –user=mysql –basedir=/application/mysql –datadir=/data/mysql/data
说明:
–initialize 参数:
对于密码复杂度进行定制:12位,4种
密码过期时间:180
报错:
mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
解决:
[[email protected] ~]# yum install -y libaio-devel [[email protected] ~]# mysqld --initialize --user=mysql --basedir=/application/mysql --datadir=/data/mysql/data2019-06-13T04:21:27.706564Z 1 [Note] A temporary password is generated for [email protected]: =mrV)_16is4U - 无限制版 --initialize-insecure 参数: 无限制,无临时密码
[[email protected] /data/mysql/data]# rm -rf /data/mysql/data/*
[[email protected] ~]# mysqld –initialize-insecure –user=mysql –basedir=/application/mysql –datadir=/data/mysql/data
配置文件的准备
cat >/etc/my.cnf <<EOF
[mysqld]
user=mysql
basedir=/application/mysql
datadir=/data/mysql/data
socket=/tmp/mysql.sock
server_id=6
port=3306
[mysql]
socket=/tmp/mysql.sock
EOF
启动数据库
sys -v
[[email protected] /etc/init.d]# cp /application/mysql/support-files/mysql.server /etc/init.d/mysqld
[[email protected] /etc/init.d]# service mysqld restart
systemd
注意: sysv方式启动过的话,需要先提前关闭,才能以下方式登录
cat >/etc/systemd/system/mysqld.service <<EOF
[Unit]
Description=MySQL Server
Documentation=man:mysqld(8)
Documentation=http://dev.mysql.com/doc/refman/en/using-systemd.html?userCode=wrvvs1rm
After=network.target
After=syslog.target
[Install]
WantedBy=multi-user.target
[Service]
User=mysql
Group=mysql
ExecStart=/application/mysql/bin/mysqld –defaults-file=/etc/my.cnf
LimitNOFILE = 5000
EOF
无法启动
without updating PID 类似错误
查看日志:
在哪?
/data/mysql/data/主机名.err
[ERROR] 上下文
可能情况:
/etc/my.cnf 路径不对等
/tmp/mysql.sock文件修改过 或 删除过
数据目录权限不是mysql
参数改错了
密码设置
管理员密码的设定([email protected])
[[email protected] ~]# mysqladmin -uroot -p password oldboy123
Enter password:
忘记密码
参数:
–skip-grant-tables #跳过授权表
–skip-networking #跳过远程登录
关闭数据库
[[email protected] ~]# /etc/init.d/mysqld stop
Shutting down MySQL.. SUCCESS!
启动维护模式
[[email protected] ~]# mysqld_safe –skip-grant-tables –skip-networking &
登录并修改密码
mysql> alter user root@’localhost’ identified by ‘1’;
ERROR 1290 (HY000): The MySQL server is running with the –skip-grant-tables option so it cannot execute this statement
mysql> flush privileges;
mysql> alter user root@’localhost’ identified by ‘1’;
Query OK, 0 rows affected (0.01 sec)
关闭数据库,正常启动验证
[[email protected] ~]# /etc/init.d/mysqld restart
[[email protected] ~]# mysql -u root -p
你还在原价购买阿里云、腾讯云、华为云、天翼云产品?那就亏大啦!现在申请成为四大品牌云厂商VIP用户,可以3折优惠价购买云服务器等云产品,并且可享四大云服务商产品终身VIP优惠价,还等什么?赶紧点击下面对应链接免费申请VIP客户吧:
相关文章
- 闻道Go语言,6月龄必知必会
- Go语言正/反向代理的姿势
- 你认识的C# foreach语法糖,真的是全部吗?
- PhpStudy 2016搭建-DVWA靶场
- c++——构造函数和析构函数
- 深入浅出学习Linux
- git相关问题解析,你想要的都有?
- Go | 闭包的使用
- linux安装stable diffusion2.0完整教程-还不会安装sd2.0?一篇文章教会你AI绘画
- arm Linux中dma的cache管理
- 嵌入式:数据处理指令详解
- golang go-sql-driver gorm 数据库报错 bad connection
- linux 命令之 ls 命令详解
- git help 查看命令手册
- 【6】python生成数据曲线平滑处理——(Savitzky-Golay 滤波器、convolve滑动平均滤波)方法介绍,推荐玩强化学习的小伙伴收藏
- 数据挖掘机器学习[四]---汽车交易价格预测详细版本{嵌入式特征选择(XGBoots,LightGBM),模型调参(贪心、网格、贝叶斯调参)}
- 像go 一样 打造.NET 单文件应用程序的编译器项目bflat 发布 7.0版本
- 解决idea登录github出现的invalid authentication data 404 not found以及登录 token 失效
- 虹科方案|将以太网连接添加到Dell EMC PowerVault™ ML3 SAS库
- Linux运维常用shell脚本之系统管理实例