当前位置: 首页 > news >正文

CentOS下安装MySQL 8.1及备份配置

1 卸载原来的MySQL版本

移除之前部署的mysql软链接

# unlink /etc/init.d/mysql
# unlink /usr/bin/mysql

2 下载最新的MySQL版本

https://dev.mysql.com/downloads/mysql/8.0.html
在这里插入图片描述

我这里直接把地址放在这里:https://cdn.mysql.com//Downloads/MySQL-8.1/mysql-8.1.0-linux-glibc2.28-x86_64.tar.xz

3. 部署安装

3.1 解压

# tar -xf mysql-8.1.0-linux-glibc2.28-x86_64.tar.xz
# mv mysql-8.1.0-linux-glibc2.28-x86_64 mysql
# mv mysql /usr/local/

3.2 添加mysql用户组

检查有无安装过mysql 用户组,没有的话创建。

//检查mysql 用户组是否存在
cat /etc/group | grep mysql
cat /etc/passwd |grep mysql// 创建mysql 用户组和用户
groupadd mysql
useradd -r -g mysql mysql

3.3 更改用户组和用户和权限

更改mysql 目录下所有文件夹所属的用户组和用户,以及权限

# chown -R mysql:mysql /usr/local/mysql
# chmod -R 755 /usr/local/mysql

3.4 编写/etc/my.cnf配置文件

[mysqld]
datadir=/usr/local/mysql/data
log-bin=/usr/local/mysql/data/mysql-bin
port = 3306
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
symbolic-links=0
max_connections=400
innodb_file_per_table=1
#表名大小写不明感,敏感为
lower_case_table_names=1

3.5 初始化mysql

# cd /usr/local/mysql/bin/
# ./mysqld --initialize --user=mysql --datadir=/usr/local/mysql/data --basedir=/usr/local/mysql
2023-09-26T14:05:58.288546Z 0 [System] [MY-015017] [Server] MySQL Server Initialization - start.
2023-09-26T14:05:58.289713Z 0 [Warning] [MY-011070] [Server] 'Disabling symbolic links using --skip-symbolic-links (or equivalent) is the default. Consider not using this option as it' is deprecated and will be removed in a future release.
2023-09-26T14:05:58.289734Z 0 [Warning] [MY-010915] [Server] 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release.
2023-09-26T14:05:58.289784Z 0 [System] [MY-013169] [Server] /usr/local/mysql/bin/mysqld (mysqld 8.1.0) initializing of server in progress as process 519016
2023-09-26T14:05:58.298375Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2023-09-26T14:05:59.009222Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2023-09-26T14:06:01.021504Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: 1;r<VeicZsN?
2023-09-26T14:06:04.449552Z 0 [System] [MY-015018] [Server] MySQL Server Initialization - end.

3.6 添加软链接,启动mysql

//添加软连接
ln -s /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
ln -s /usr/local/mysql/bin/mysql /usr/bin/mysql//重启mysql服务
service mysql restart

3.7 修改密码,开放远程链接

# mysql -u root -p
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'youpassword';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> update user set user.Host='%' where user.User='root';
Query OK, 1 row affected (0.01 sec)
Rows matched: 1  Changed: 1  Warnings: 0mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

3.8 设置开机自启

//将服务文件拷贝到init.d下,并重命名为mysql
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
//赋予可执行权限
chmod +x /etc/init.d/mysqld
//添加服务
chkconfig --add mysqld
//显示服务列表
chkconfig --list
http://www.lryc.cn/news/176245.html

相关文章:

  • 【RabbitMQ实战】06 3分钟部署一个RabbitMQ集群
  • (c语言)整形提升
  • 上传文件报错:The temporary upload location [/tmp/tomcat/xxx] is not valid
  • 直线模组的品牌有哪些?
  • 零基础学习ESP8266
  • 基于PYQT5的GUI开发系列教程【二】框架安装和基础环境配置
  • pg数据库操作,insert(sql)插入一条数据后获返回当前插入数据的id --chatGPT
  • 【数据结构-树】哈夫曼树
  • HarmonyOS 4.0 实况窗上线!支付宝实现医疗场景智能提醒
  • 【响应式布局】
  • Spring面试题23:Spring支持哪些事务管理类型?Spring框架的事务管理有哪些优点?你更倾向用哪种事务管理类型?
  • Leetcode—— LCR 122. 路径加密
  • 缓冲区溢出漏洞分析
  • 【高阶数据结构】红黑树(C++实现)
  • 算力百川汇蓝海,商海荡漾绘宏图
  • ORACLE 内存结构之系统全局区(SGA)
  • 主要文档分享网站一览
  • CPU访问一个虚拟地址的整体流程
  • UE5 虚幻引擎 如何使用构造脚本(Construction Script)? 构造脚本的奥秘!
  • Mysql高级——数据库设计规范(2)
  • c++-string
  • KNN-K近邻算法(K-Nearest Neighbors)
  • ChatGPT:理解HTTP请求数据格式:JSON、x-www-form-urlencoded和form-data
  • 字符集、IO流(一)
  • 相乘(蓝桥杯)
  • [AFCTF 2018]你能看出这是什么加密么
  • 基于springboot+vue的重庆旅游网(前后端分离)
  • pymysql执行delete删除操作
  • 25862-2010 制冷与空调用同轴套管式换热器
  • JetBrains 产品安装插件(plugins)的两种方式