1、MySQL 8.0.26 下载

官方网站下载 MySQL 8.0.26 安装包,下载地址:

https://downloads.mysql.com/archives/community/

需要注意:Linux操作系统是32位还是64位,本案例采用Linux 64位操作系统进行讲解,通过wget命令下载安装包。

使用df -lh命令查看,磁盘大小,尽量安装在比较大的磁盘下,防止空间不够使用。

[root@VM-0-4-centos home]# df -lh
Filesystem Size Used Avail Use% Mounted on
devtmpfs 3.9G 0 3.9G 0% /dev
tmpfs 3.9G 24K 3.9G 1% /dev/shm
tmpfs 3.9G 604K 3.9G 1% /run
tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
/dev/vda1 50G 3.8G 44G 9% /
tmpfs 783M 0 783M 0% /run/user/0

通过上述命令可以看出根目录空间比较充足,那么就把安装包下载到home目录了,执行wget命令。

[root@VM-0-4-centos home]# wget https://downloads.mysql.com/archives/get/p/23/file/mysql-8.0.26-linux-glibc2.12-x86_64.tar.xz

  

2、解压缩文件

解压 mysql-8.0.26-linux-glibc2.12-x86_64.tar.xz 文件,使用tar -xvf mysql-8.0.26-linux-glibc2.12-x86_64.tar.xz 命令。

[root@VM-0-4-centos home]# tar -xvf mysql-8.0.26-linux-glibc2.12-x86_64.tar.xz
mysql-8.0.26-linux-glibc2.12-x86_64/bin/
mysql-8.0.26-linux-glibc2.12-x86_64/bin/myisam_ftdump
mysql-8.0.26-linux-glibc2.12-x86_64/bin/myisamchk
mysql-8.0.26-linux-glibc2.12-x86_64/bin/myisamlog
mysql-8.0.26-linux-glibc2.12-x86_64/bin/myisampack
mysql-8.0.26-linux-glibc2.12-x86_64/bin/mysql
....
mysql-8.0.26-linux-glibc2.12-x86_64/share/
mysql-8.0.26-linux-glibc2.12-x86_64/share/install_rewriter.sql
mysql-8.0.26-linux-glibc2.12-x86_64/share/uninstall_rewriter.sql

  

3、移动文件

将压缩包移动到usr/local目录下,并重命名文件为mysql,使用mv /home/mysql-8.0.26-linux-glibc2.12-x86_64  /usr/local/mysql命令。

[root@VM-0-4-centos home]# mv mysql-8.0.26-linux-glibc2.12-x86_64 /usr/local/mysql
[root@VM-0-4-centos home]# cd /usr/local/mysql/
[root@VM-0-4-centos mysql]# ls
bin docs include lib LICENSE man README share support-files
[root@VM-0-4-centos mysql]# cd ..
[root@VM-0-4-centos local]# ls
bin etc games include lib lib64 libexec mysql qcloud sbin share src yd.socket.server
[root@VM-0-4-centos local]#

  

4、创建数据存放目录

在mysql根目录下新建一个目录data,主要用于存放数据库数据文件,使用mkdir data命令。

[root@VM-0-4-centos local]# cd mysql/
[root@VM-0-4-centos mysql]# mkdir data
[root@VM-0-4-centos mysql]# ls
bin data docs include lib LICENSE man README share support-files
[root@VM-0-4-centos mysql]#

  

5、创建用户组和用户

创建mysql用户组和mysql用户,使用groupadd mysql和useradd -g mysql mysql命令。

[root@VM-0-4-centos mysql]# groupadd mysql
[root@VM-0-4-centos mysql]# useradd -g mysql mysql

  

6、改变mysql目录权限

修改mysql目录权限,可以使用chown -R mysql.mysql /usr/local/mysql/命令。

修改mysql目录权限也可以通过chown -R mysql .和chgrp -R mysql .两个命令。注意:这两个命令都需要执行的,还有那个点不要忽视掉。

7、数据库初始化

数据库初始化./bin/mysqld --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --initialize命令,得到临时密码。

2022-01-16T07:32:18.729960Z 0 [System] [MY-013169] [Server] /usr/local/mysql/bin/mysqld (mysqld 8.0.26) initializing of server in progress as process 7691
2022-01-16T07:32:18.740975Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2022-01-16T07:32:19.800287Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2022-01-16T07:32:21.721672Z 0 [Warning] [MY-013746] [Server] A deprecated TLS version TLSv1 is enabled for channel mysql_main
2022-01-16T07:32:21.722106Z 0 [Warning] [MY-013746] [Server] A deprecated TLS version TLSv1.1 is enabled for channel mysql_main
2022-01-16T07:32:21.787669Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: j-6lA2aXv=Pz

需要注意:记录一下mysql数据库的临时密码 j-6lA2aXv=Pz,后面安装步骤是需要使用的,否则需要重新安装数据库或其他方式获取密码,此处问题省略。另外,关于更多其他软件安装配置步骤,如redis、kafka、fastdfs、elasticsearch等中间件安装配置图文步骤,公众号Java精选,回复中间件三个汉字,获取所有软件安装步骤。切勿乱回复,否则什么也没有!!!

8、修改my.cnf文件

修改my.cnf文件,使用vim 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命令,保存并退出。

9、创建mysql服务

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

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

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

[root@VM-0-4-centos mysql]# cp -a /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
[root@VM-0-4-centos mysql]# chmod +x /etc/rc.d/init.d/mysqld
[root@VM-0-4-centos mysql]# chkconfig --add mysqld

检查mysql服务是否生效,使用chkconfig  --list mysqld命令。

[root@VM-0-4-centos mysql]# chkconfig  --list mysqld

Note: This output shows SysV services only and does not include native
systemd services. SysV configuration data might be overridden by native
systemd configuration. If you want to list systemd services use 'systemctl list-unit-files'.
To see services enabled on particular target use
'systemctl list-dependencies [target]'. mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off

  

10、配置全局环境变量

编辑/etc/profile文件,使用vim /etc/profile命令,在profile文件中添加如下两行配置,使用:wq命令保存后退出。

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

设置环境变量立即生效使用source /etc/profile命令。

[root@VM-0-4-centos ~]# source /etc/profile
[root@VM-0-4-centos ~]#

  

11、启动mysql服务

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

[root@VM-0-4-centos ~]# service mysql start
Redirecting to /bin/systemctl start mysql.service
[root@VM-0-4-centos ~]# 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.

  

12、登录mysql修改密码

登录mysql数据库,使用mysql -uroot -p密码命令,临时密码是j-6lA2aXv=Pz。

[root@VM-0-4-centos ~]# 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>

修改mysql临时密码,也就是将第七步数据库初始化生成的临时密码修改成自己需要设置的密码。

修改mysql数据库密码,使用ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';命令。

mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';
Query OK, 0 rows affected (0.01 sec)
mysql>

注意:此处123456修改为自己的需要密码即可。

13、设置mysql远程登录

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

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

3)刷新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>

  

14、mysql客户端连接数据库

客户端连接mysql数据库,连接名(自定义名称)、主机(IP)、端口号及用户名和密码,点击测试连接按钮,显示连接成功即可。

注意:若提示无法连接,需要测试服务器3306端口是否开放。若服务器端可以通过查看防火墙情况,此时方式验证省略;而从客户端测试可以使用“telnet IP 端口号”命令。

Linux 安装 MySQL 8.0.26 超详细图文步骤的更多相关文章

  1. 硬盘安装CentOS 6.0(超级详细图文教程)

    硬盘安装CentOS 6.0(超级详细图文教程) 来源:   引言: 电脑系统是Windows XP,电脑没有光驱.手头没有U盘.没有移动硬盘.电脑主板不支持U盘启动,在这种情况下想安装CentOS ...

  2. CentOS 7安装MySQL 8——萌新超详细教程

          1.配置MySQL 8.0的安装源:   sudo rpm -Uvh https://dev.mysql.com/get/mysql80-community-release-el7-1.n ...

  3. Linux安装mysql.8.0.12

    1. linux安装mysql8.0.12,亲测可用. 以下是安装过程中出现的问题: 1 [root@localtest1 file]# systemctl start mysqld 2 Job fo ...

  4. Linux中安装MySql 5.7.21的详细操作步骤

    一:到mysql官网下载最新的mysql包 mysql-5.7.21-linux-glibc2.12-x86_64 官方下载地址:https://dev.mysql.com/downloads/mys ...

  5. Linux 安装 MySQL 8 数据库(图文详细教程)

    本教程手把手教你如何在 Linux 安装 MySQL 数据库,以 CentOS 7为例. 1. 下载并安装 MySQL 官方的 Yum Repository wget -i -c https://re ...

  6. 安装64位Oracle 10g超详细教程

    安装64位Oracle 10g超详细教程 1. 安装准备阶段 1.1 安装Oracle环境 经过上一篇博文的过程,已经完成了对Linux系统的安装,本例使用X-Manager来实现与Linux系统的连 ...

  7. 在 CentOS 7.5 64位上使用 yum 安装 MySQL 8.0

    前段时间在 CentOS 7.5 64位上安装 MySQL 8.0.查了些资料,在这里记录一下详细的安装和设置步骤. 一.安装 使用yum安装MySQL之前需要先下载对应的.rpm文件,下载方法: 去 ...

  8. linux安装mysql全纪录[包括yum和rpm安装,编码,远程连接以及大小写问题]

    linux安装mysql全纪录[包括yum和rpm安装,编码,远程连接以及大小写问题] 一.查看mysql是否已经安装 使用“whereis mysql”命令来查看mysql安装路径: [root@h ...

  9. Linux 安装Mysql(图文教程)

    原文:Linux 安装Mysql(图文教程) 版权声明:本文为博主原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明. 本文链接:https://blog.csdn.net ...

随机推荐

  1. [BUUCTF]PWN7——[OGeek2019]babyrop

    [BUUCTF]PWN7--[OGeek2019]babyrop 题目网址:https://buuoj.cn/challenges#[OGeek2019]babyrop 步骤: 例行检查,32位,开启 ...

  2. Table.Distinct取唯/众数….Distinct/Mode/判断…IsDistinct(Power Query 之 M 语言)

    数据源: "姓名""基数""个人比例""个人缴纳""公司比例""公司缴纳"&qu ...

  3. CF999C Alphabetic Removals 题解

    Content 给定一个长度为 \(n\) 的仅含小写字母的字符串,执行 \(k\) 次如下操作: 如果字符串中有 a 这个字母,删除从左往右第一个 a,并结束操作,否则继续操作: 如果字符串中有 b ...

  4. Shell脚本--数值比较组合判断

    用于数值比较的无非大于.小于.等于.大于等于.小于等于这几个. 比较格式: [ 数值1 比较符 数值2 ]   注意左边的括号与数值1之间有一个空格,同样,数值2和右边的括号之间也有空格. 数值比较运 ...

  5. ligerUI问题

    1.checkboxColWidth:990,Grid的复选框的宽度设置为什么不起作用. 2.当grid出现横线不对齐时,可以设置detailColWidth:90,属性进行设置.此属性好像只是针对复 ...

  6. JAVA调用阿里云短信接口

    官方文档:https://help.aliyun.com/document_detail/101414.html?spm=a2c4g.11186623.6.626.2cef6220yxh5l7 jar ...

  7. Java整合redis报错s if RDB snapshotting fails (stop-writes-on-bgsave-error option)

    Caused by: io.lettuce.core.RedisCommandExecutionException: MISCONF Redis is configured to save RDB s ...

  8. Spring Boot去掉浏览器默认的叶子图标

    在Spring Boot的配置文件application.properites中添加配置项,可以关闭默认的Favicon spring.mvc.favicon.enabled=false

  9. 【LeetCode】862. Shortest Subarray with Sum at Least K 解题报告(C++)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 队列 日期 题目地址:https://leetcod ...

  10. 【LeetCode】Pascal's Triangle II 解题报告

    [LeetCode]Pascal's Triangle II 解题报告 标签(空格分隔): LeetCode 题目地址:https://leetcode.com/problems/pascals-tr ...