mysql8.0版本安装图解教程,mysql8.0.20安装教程图解

首页 > 经验 > 作者:YD1662022-11-04 05:23:17

本文以 mysql-8.0.28 为例,编写安装教程,本文安装环境是 CentOS

1. 首先在官网下载对应版本,此步骤我相信大家都会,就不再赘述

2. 创建 mysql 组和 mysql 用户

```shell shell> groupadd mysql shell> useradd -r -g mysql -s /bin/false mysql ```

3. 将下载的 MySQL 压缩文件,拷贝到 /usr/local/, 并解压,创建软连接

```shell shell> cp mysql-8.0.28-linux-glibc2.12-x86_64.tar.xz /usr/local shell> tar -xvf mysql-8.0.28-linux-glibc2.12-x86_64.tar.xz shell> ln -s mysql-8.0.28-linux-glibc2.12-x86_64 mysql ```

4. 创建 mysql-files 并修改其属主和属组

```shell shell> cd mysql shell> mkdir mysql-files shell> chown mysql:mysql mysql-files shell> chmod 750 mysql-files ```

5. 创建 MySQL 数据目录,创建 MySQL 全局配置文件

```shell # 创建数据文件 shell> cd /opt shell> mkdir -p mysql_data/mysql80 # 创建配置文件 shell> vim my.cnf # 内容如下 [mysqld] port = 3306 user = mysql datadir = /opt/mysql_data/mysql80 log_error = error.log ```

6. 初始化数据,并修改 MySQL 安装目录的属组为 root

```shell shell> bin/mysqld --initialize --user=mysql # --initialize-insecure 无密码 bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory shell> yum install libaio shell> mysqld --initialize --user=mysql # 再次执行成功 shell> bin/mysql_ssl_rsa_setup shell> chown -R root . ```

7. 启动 MySQL

```shell shell> cp support-files/mysql.server /etc/init.d/mysqld shell> service mysqld start # 启动 mysql 服务,或者: systemctl start mysqld shell> service mysqld status # 查看 mysql 状态,或者: systemctl status mysqld shell> service mysqld stop # 停止 mysql 服务,或者: systemctl stop mysqld ```

8. 登录 MySQL

```shell shell> export PATH=/usr/local/mysql/bin:$PATH #配置环境变量 shell> mysql -uroot -p # 再次登录,在 /opt/mysql_data/mysql80/error.log 查找密码,如下: 2022-03-03T03:33:49.812373Z 1 [Note] A temporary password is generated for root@localhost: 4ojuihu(OhBw ```

9. 修改密码

```shell shell> mysql -uroot -p # 登录 Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 9 Server version: 8.0.28 MySQL Community Server - GPL Copyright (c) 2000, 2022, 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> set password = '123'; # 修改密码 ```

至此,现在企业常用 MySQL 版本的安装教程都写完了,安装完成之后如何链接 MySQL呢?下一篇说一下 MySQL 的链接 ,敬请期待......

大家加油!!!

下面是广告时间,关注 “老刘说技术” 获取更多教程

mysql8.0版本安装图解教程,mysql8.0.20安装教程图解(1)

栏目热文

文档排行

本站推荐

Copyright © 2018 - 2021 www.yd166.com., All Rights Reserved.