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

Mysql 5.7.26 安装

Mysql 5.7.26 安装

1、解压并移动
tar -xvf mysql-advanced-5.7.26-linux-glibc2.12-x86_64.tar.gz  
mv mysql-advanced-5.7.26-linux-glibc2.12-x86_64/ /usr/local/mysql-5.7.26


2、创建 用户,并给数据目录赋予权限
groupadd mysql
useradd -r -g mysql mysql


3、创建mysq数据目录
mkdir -p /data
cd /data/
mkdir -p mysql
chown mysql:mysql -R /data/mysql


4、配置参数
vim /etc/my.cnf
[mysqld]
bind-address=0.0.0.0
port=3306
user=mysql
basedir=/usr/local/mysql-5.7.26
datadir=/data/mysql
socket=/tmp/mysql.sock

#character config
character_set_server=utf8mb4
symbolic-links=0
explicit_defaults_for_timestamp=true
sql_mode=STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

[mysqld_safe]
log-error=/data/mysql/mysql.err
pid-file=/data/mysql/mysql.pid


5、初始化mysql
# cd /usr/local/mysql-5.7.26/bin/
# ./mysqld --defaults-file=/etc/my.cnf --basedir=/usr/local/mysql-5.7.26/ --datadir=/data/mysql/ --user=mysql --initialize
2025-11-10T02:31:40.748640Z 0 [Warning] '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.
100
100
100
2025-11-10T02:32:02.984938Z 0 [Warning] InnoDB: New log files created, LSN=45790
2025-11-10T02:32:03.314752Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2025-11-10T02:32:03.402117Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 71416dec-bddd-11f0-8e4b-000c29fadf64.
2025-11-10T02:32:03.404596Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2025-11-10T02:32:05.425531Z 0 [Warning] CA certificate ca.pem is self signed.
2025-11-10T02:32:06.048298Z 1 [Note] A temporary password is generated for root@localhost: oYU%R%T>e6UY
[root@yashan bin]# 


6、修改启动配置
cd /usr/local/mysql-5.7.26/support-files
# cp mysql.server /etc/init.d/mysqld
# vim /etc/init.d/mysqld
basedir=/usr/local/mysql-5.7.26
datadir=/data/mysql

配置开启自启
如果rc.local文件没有执行权限,所以需要手动开启:
echo "service mysql start" >> /etc/rc.local


7、启动mysql,并更改root 密码
# /etc/init.d/mysqld start
Starting MySQL.Logging to '/data/mysql/mysql.err'.
.......... SUCCESS! 
# ./mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.26-enterprise-commercial-advanced

Copyright (c) 2000, 2019, 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> alter user root@'localhost' identified by 'root';
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)


注:需要设置root用户可以远程访问,需执行如下命令: 
mysql> grant all privileges on *.* to root@'192.168.142.1' identified by 'root' with grant option;
mysql> flush privileges;

http://www.dtcms.com/a/593026.html

相关文章:

  • 【ZeroRange WebRTC】码学基础与实践:哈希、HMAC、AES、RSA/ECDSA、随机数、X.509
  • 深圳做手机网站建设中小企业网站建设多少钱
  • 【大数据技术01】数据科学的基础理论
  • 研发管理知识库(1)DevOps开发模式简介
  • 【ComfyUI/SD环境管理指南(一)】:如何避免插件安装导致的环境崩溃与快速修复
  • 深入理解 ThreadLocal、InheritableThreadLocal 与 TransmittableThreadLocal
  • 网站维护服务器广告公司叫什么名字好
  • 日语学习-日语知识点小记-构建基础-JLPT-N3阶段-二阶段(16):文法和单词-第四课
  • 破解进入网站后台wordpress域名如何申请
  • 基于 Spring Boot 与 RabbitMQ 的分布式消息通信机制设计与实现
  • 个人网站搭建详细步骤郑州网站建设流程
  • Java 之详解字符串拼接(十四)
  • Redis集群详解
  • 6 ElasticsearchRestTemplate
  • 第3章:矢量与栅格数据模型
  • java 面试问题
  • Elasticsearch-3--什么是Lucene?
  • 01-SQL 语句的关键字顺序
  • 树莓派Raspberry Pi 5的汉化
  • 小红书推荐系统(牛客)
  • 做网站的猫腻网站的链接结构怎么做
  • 【强化学习】DQN 算法
  • 大模型-详解 Vision Transformer (ViT) (2
  • 学习react第一天
  • 2025年电子会计档案管理软件深度介绍及厂商推荐
  • io_uring 避坑指南
  • (附源码)基于Spring boot的校园志愿服务管理系统的设计与实现
  • deepseek回答 如何用deepseek训练出一个我的思路
  • 3ds Max材质高清参数设置:10分钟提升渲染真实感
  • MyBatis 插件