二进制部署mysql8.0.35
创建mysql用户
[root@zyq ~]
[root@zyq ~]
uid=990( mysql) gid=990( mysql) groups=990( mysql) 上传mysql文件
[root@zyq ~]
anaconda-ks. cfg
mysql-8. 0. 35-linux-glibc2. 28-x86_64. tar. xz解压
[root@zyq ~]
[root@zyq ~]
[root@zyq local]
bin games include lib64 mysql-8. 0. 35-linux-glibc2. 28-x86_64 share
etc httpd lib libexec sbin src
[root@zyq local] 设置环境变量
[root@zyq mysql]
[root@zyq mysql]
[root@zyq mysql]
/ usr/local/mysql/bin/mysql创建软连接
[root@zyq mysql] 配置lib库文件
[root@zyq mysql]
[root@zyq mysql]
/ use/local/mysql/lib
[root@zyq mysql] 配置man文档
[root@zyq mysql]
添加此行
. . . . . .
MANDATORY_MANPATH / usr/local/mysql/man
. . . . . . 更改主/ 组
[root@zyq mysql]
[root@zyq mysql]
total 296
drwxr-xr-x. 2 mysql mysql 4096 Oct 12 22:11 bin
drwxr-xr-x. 2 mysql mysql 38 Oct 12 22:11 docs
drwxr-xr-x. 3 mysql mysql 4096 Oct 12 22:11 include
drwxr-xr-x. 6 mysql mysql 4096 Oct 12 22:11 lib
- rw-r-- r-- . 1 mysql mysql 279355 Oct 12 19:45 LICENSE
drwxr-xr-x. 4 mysql mysql 30 Oct 12 22:11 man
- rw-r-- r-- . 1 mysql mysql 666 Oct 12 19:45 README
drwxr-xr-x. 28 mysql mysql 4096 Oct 12 22:11 share
drwxr-xr-x. 2 mysql mysql 77 Oct 12 22:11 support-files创建数据库数据目录
初始化
[root@zyq mysql]
[root@zyq mysql]
2023-12-05T09:24:56. 910277Z 0 [System] [MY-013169] [Server] / usr/local/mysql/bin/mysqld ( mysqld 8. 0. 35) initializing of server in progress as process 31786
2023-12-05T09:24:56. 915155Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2023-12-05T09:24:57. 047553Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2023-12-05T09:24:58. 592274Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: n1O6QThtF; m=
保存密码方便查看
[root@zyq mysql] 配置my. cnf文件
[root@zyq mysql]
[root@zyq mysql]
[mysqld]
basedir = / usr/local/mysql
datadir = / opt/data
socket = / tmp/mysql. sock
port = 3306
pid-file = / opt/data / mysql. pid
user = mysql
skip-name - resolve配置支持文件
[root@zyq mysql]
[root@zyq support-files]
mysql. server: POSIX shell script, ASCII text executable
[root@zyq support-files]
[root@zyq support-files]
[root@zyq support-files]
- rwxr-xr-x. 1 mysql mysql 10576 Oct 12 21:47 / etc/init. d/mysqld
指名路径(安装路径,数据路径)
[root@zyq support-files]
basedir=/ use/local/mysql
datadir=/ opt/data 启动
[root@zyq support-files]
[root@zyq ~]
[root@zyq ~]
Starting MySQL. Logging to '/opt/data/zyq.err' . SUCCESS!
[root@zyq ~]
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0 128 0. 0. 0. 0:22 0. 0. 0. 0:*
LISTEN 0 511 * :80 * :*
LISTEN 0 128 [ ::] :22 [ ::] :*
LISTEN 0 70 * :33060 * :*
LISTEN 0 151 * :3306 * :*
停止服务
[root@zyq ~]
Shutting down MySQL. . SUCCESS!用配置文件方式启动,停止服务
[root@zyq ~]
[root@zyq system]
[root@zyq system]
[root@zyq system]
[Unit]
Description=mysqld server daemon
After=network. target [Service]
Type =forking
ExecStart=service mysqld start
ExecStop=service mysqld stop
ExecReload=/ bin/kill - HUP $MAINPID [Install]
WantedBy=multi-user. target
[root@zyq system]
[root@zyq system]
[root@zyq ~]
○ mysql. service - mysqld server daemonLoaded: loaded ( / usr/lib/systemd/system/mysql. service; disabled; vend>Active: inactive ( dead) [root@zyq ~]
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0 128 0. 0. 0. 0:22 0. 0. 0. 0:*
LISTEN 0 511 * :80 * :*
LISTEN 0 128 [ ::] :22 [ ::] :*
[root@zyq ~]
[root@zyq ~]
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0 128 0. 0. 0. 0:22 0. 0. 0. 0:*
LISTEN 0 511 * :80 * :*
LISTEN 0 128 [ ::] :22 [ ::] :*
LISTEN 0 70 * :33060 * :*
LISTEN 0 151 * :3306 * :*
[root@zyq ~]
● mysql. service - mysqld server daemonLoaded: loaded ( / usr/lib/systemd/system/mysql. service; disabled; vend>Active: active ( running) since Tue 2023-12-05 17:52:41 CST; 14s agoProcess : 32503 ExecStart=service mysqld start ( code=exited, status=0/S>Main PID: 32524 ( mysqld_safe) Tasks: 39 ( limit: 48715) Memory: 370. 6MCPU: 520msCGroup: / system. slice/mysql. service├─32524 / bin/sh / usr/local/mysql/bin/mysqld_safe -- datadir=/ o>└─32714 / usr/local/mysql/bin/mysqld -- basedir=/ usr/local/mysq>Dec 05 17:52:40 zyq systemd[ 1] : Starting mysqld server daemon. . .
Dec 05 17:52:41 zyq service[ 32507] : Starting MySQL. SUCCESS!
Dec 05 17:52:41 zyq systemd[ 1] : Started mysqld server daemon. 设置开机自启
[root@zyq ~]
Created symlink / etc/systemd/system/multi-user. target. wants/mysql. service → / usr/lib/systemd/system/mysql. service.
[root@zyq ~]
● mysql. service - mysqld server daemonLoaded: loaded ( / usr/lib/systemd/system/mysql. service; enabled; vendo>Active: active ( running) since Tue 2023-12-05 17:52:41 CST; 2min 15s >Main PID: 32524 ( mysqld_safe) Tasks: 38 ( limit: 48715) Memory: 370. 6MCPU: 1. 075sCGroup: / system. slice/mysql. service├─32524 / bin/sh / usr/local/mysql/bin/mysqld_safe -- datadir=/ o>└─32714 / usr/local/mysql/bin/mysqld -- basedir=/ usr/local/mysq>Dec 05 17:52:40 zyq systemd[ 1] : Starting mysqld server daemon. . .
Dec 05 17:52:41 zyq service[ 32507] : Starting MySQL. SUCCESS!
Dec 05 17:52:41 zyq systemd[ 1] : Started mysqld server daemon. 重启检测
[root@zyq ~]
[root@zyq ~]
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0 128 0. 0. 0. 0:22 0. 0. 0. 0:*
LISTEN 0 128 ::] :22 [ ::] :*
LISTEN 0 70 * :33060 * :*
LISTEN 0 151 * :3306 * :*
设置数据库密码
使用初始化的密码登录
[root@zyq ~] mysql> alter user 'root' @'localhost' identified with mysql_native_password by 'Pssword@_' ;