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

Linux(CentOS8)系统安装mysql-8.0.26-linux-glibc2.12-x86_64.tar.xz

一、下载获取 mysql安装包;

MySQL :: Download MySQL Community Server (Archived Versions)

二、安装步骤

1、切换到安装目录下,并解压

tar -zxvf mysql-8.0.26-linux-glibc2.12-x86_64.tar.xz

2.移动解压后的文件并且重命名为mysql

 mv mysql-8.0.26-linux-glibc2.12-x86_64 /usr/local

 3.先切换至mysql文件夹下创建新文件夹data

cd /usr/local/mysql

 

4.创建mysql用户组和mysql用户

groupadd mysql

useradd -g mysql mysql 

 5.修改mysql目录权限

chown -R mysql.mysql /usr/local/mysql/

6.数据库初始化

注意事项:记录一下mysql数据库的临时密码*************,后面安装步骤是需要使用的!

./bin/mysqld --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --initialize

 7.修改my.cnf文件

vi  /etc/my.cnf

 [mysqld]
    basedir = /usr/local/mysql
    datadir = /usr/local/mysql/data
    socket = /usr/local/mysql/mysql.sock
    character-set-server=utf8
    port = 3306
    sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
 [client]
    socket = /usr/local/mysql/mysql.sock
    default-character-set=utf8
#[mysqld]
#datadir=/var/lib/mysql
#socket=/var/lib/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
#symbolic-links=0
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd
 
#[mysqld_safe]
#log-error=/var/log/mariadb/mariadb.log
#pid-file=/var/run/mariadb/mariadb.pid
 
#
# include all files from the config directory
#
#!includedir /etc/my.cnf.d

直接将上述配置内容复制到my.cnf文件中,或者自行修改,然后执行:wq命令,保存并退出 

8.创建mysql服务 

a)将mysql.server启动文件复制到/etc/init.d目录,使用cp -a /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld命令。

b)赋予权限,使用chmod +x /etc/rc.d/init.d/mysqld命令;

c)使用chkconfig --add mysqld创建mysql服务。

按照顺序执行!

cp -a /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/rc.d/init.d/mysqld 
chkconfig --add mysqld 

9.配置环境变量 

vi /etc/profile

将下面配置添加到export 环境变量配置文件中

export PATH=$PATH:/usr/local/mysql/bin:/usr/local/mysql/lib
export PATH

设置环境变量立即生效

source /etc/profile 

10.启动mysql服务

使用service mysql start命令;使用service mysql status命令,查看是否启动成功。 

[root ~]# service mysql start
Redirecting to /bin/systemctl start mysql.service
[root ~]# service mysql status
Redirecting to /bin/systemctl status mysql.service
● mysqld.service - LSB: start and stop MySQL
   Loaded: loaded (/etc/rc.d/init.d/mysqld; bad; vendor preset: disabled)
   Active: active (running) since Sun 2022-01-16 17:17:55 CST; 8s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 27231 ExecStart=/etc/rc.d/init.d/mysqld start (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/mysqld.service
           ├─27242 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/usr/local/mysql/data --pid-file=/usr/local/mysql/data/VM-0-4-centos.pid
           └─27408 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=VM-0-4-cent...
 
Jan 16 17:17:54 VM-0-4-centos systemd[1]: Starting LSB: start and stop MySQL...
Jan 16 17:17:54 VM-0-4-centos mysqld[27231]: Starting MySQL.Logging to '/usr/local/mysql/data/VM-0-4-centos.err'.
Jan 16 17:17:55 VM-0-4-centos mysqld[27231]: SUCCESS!
Jan 16 17:17:55 VM-0-4-centos systemd[1]: Started LSB: start and stop MySQL. 

11.登陆mysql并且修改密码

这里输入的密码为 第 6 步初始化的默认密码

[root ~]# mysql -uroot -p
Enter password: 键入初始密码
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 13
Server version: 8.0.26
 
Copyright (c) 2000, 2021, Oracle and/or its affiliates.
 
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 WITH mysql_native_password BY 'root123456';
Query OK, 0 rows affected (0.01 sec)
mysql> 

12.设置mysql远程登录后可使用客户端进行连接 

a)切换数据库,使用use mysql;命令。

b)修改mysql库中host值,使用update user set host='%' where user='root' limit 1;命令。

c)刷新mysql权限,使用flush privileges;命令。

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 -A
 
Database changed
mysql> update user set host='%' where user='root' limit 1;
Query OK, 1 row affected (0.01 sec)
Rows matched: 1  Changed: 1  Warnings: 0
 
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
 
mysql>

相关文章:

  • 北京网站建设多少钱?
  • 辽宁网页制作哪家好_网站建设
  • 高端品牌网站建设_汉中网站制作
  • 制造业中的MES知识与ERP\PLM\WMS架构关系(附智能制造MES解决方案PPT下载)
  • 极限基础:变化率在manim中的实现
  • 【数据科学概述】数据科学的基本概念与发展历程】
  • 2408gui,学习gui的经验
  • 超详细Git基本命令使用(二)
  • UNI-APP 打包构建 APK
  • 微信小程序代码目录结构介绍
  • 数据结构概念
  • ‌分布式计算技术与复杂算法优化:‌现代数据处理的基石
  • Java 应用的熔断机制:服务降级与恢复
  • Python酷库之旅-第三方库Pandas(104)
  • 打卡56天------图论(冗余连接)
  • vue调用booststrap弹窗
  • Datawhle X 李宏毅苹果书AI夏令营深度学习笔记之——局部最小值与鞍点
  • CSS3视图过渡动画
  • canvas绘制圆角头像
  • create-react-app项目添加less配置
  • Docker 笔记(1):介绍、镜像、容器及其基本操作
  • java8 Stream Pipelines 浅析
  • MySQL QA
  • MySQL用户中的%到底包不包括localhost?
  • SQLServer之索引简介
  • Sublime Text 2/3 绑定Eclipse快捷键
  • 基于web的全景—— Pannellum小试
  • 基于组件的设计工作流与界面抽象
  • 力扣(LeetCode)22
  • 手写一个CommonJS打包工具(一)
  • 为视图添加丝滑的水波纹
  • 小程序 setData 学问多
  • 验证码识别技术——15分钟带你突破各种复杂不定长验证码
  • 【干货分享】dos命令大全
  • 阿里云IoT边缘计算助力企业零改造实现远程运维 ...
  • 新海诚画集[秒速5センチメートル:樱花抄·春]
  • # windows 安装 mysql 显示 no packages found 解决方法
  • (16)UiBot:智能化软件机器人(以头歌抓取课程数据为例)
  • (4) openssl rsa/pkey(查看私钥、从私钥中提取公钥、查看公钥)
  • (C语言版)链表(三)——实现双向链表创建、删除、插入、释放内存等简单操作...
  • (function(){})()的分步解析
  • (附源码)计算机毕业设计SSM疫情居家隔离服务系统
  • (十六)串口UART
  • (转)菜鸟学数据库(三)——存储过程
  • .NET 8 跨平台高性能边缘采集网关
  • .NET WPF 抖动动画
  • .NET 直连SAP HANA数据库
  • .net安装_还在用第三方安装.NET?Win10自带.NET3.5安装
  • .NET精简框架的“无法找到资源程序集”异常释疑
  • .net通用权限框架B/S (三)--MODEL层(2)
  • 。Net下Windows服务程序开发疑惑
  • @ModelAttribute使用详解
  • @SpringBootApplication 包含的三个注解及其含义
  • [ CTF ] WriteUp- 2022年第三届“网鼎杯”网络安全大赛(朱雀组)
  • [20180224]expdp query 写法问题.txt
  • [BSGS算法]纯水斐波那契数列
  • [BSidesCF 2019]Kookie1
  • [BUUCTF]-Reverse:reverse3解析