当前位置:   article > 正文

二进制源码部署mysql8.0.35

二进制源码部署mysql8.0.35

二进制部署mysql8.0.35

创建mysql用户
[root@zyq ~]#: useradd -r -s /sbin/nologin -M mysql
[root@zyq ~]#: id mysql 
uid=990(mysql) gid=990(mysql) groups=990(mysql)

上传mysql文件
[root@zyq ~]#: ls
anaconda-ks.cfg  
mysql-8.0.35-linux-glibc2.28-x86_64.tar.xz



解压
[root@zyq ~]#: tar xf mysql-8.0.35-linux-glibc2.28-x86_64.tar.xz -C  /usr/local/
[root@zyq ~]#: cd /usr/local/
[root@zyq local]#: ls
bin  games  include  lib64    mysql-8.0.35-linux-glibc2.28-x86_64  share
etc  httpd  lib      libexec  sbin                                 src
[root@zyq local]#: mv mysql-8.0.35-linux-glibc2.28-x86_64/ mysql

设置环境变量
[root@zyq mysql]#: echo 'export PATH=/usr/local/mysql/bin:$PATH' > /etc/profile.d/mysql.sh
[root@zyq mysql]#: source /etc/profile.d/mysql.sh 
[root@zyq mysql]#: which mysql
/usr/local/mysql/bin/mysql

创建软连接
[root@zyq mysql]#: ln -s /usr/local/mysql/include /usr/include/mysql

配置lib库文件
[root@zyq mysql]#: vi /etc/ld.so.conf.d/mysql.conf
[root@zyq mysql]#: cat /etc/ld.so.conf.d/mysql.conf
/use/local/mysql/lib
[root@zyq mysql]#: ldconfig 

配置man文档
[root@zyq mysql]#: vi /etc/man_db.conf
添加此行
......
MANDATORY_MANPATH                       /usr/local/mysql/man
......

更改主/[root@zyq mysql]#: chown -R mysql.mysql /usr/local/mysql
[root@zyq mysql]#: ll /usr/local/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]#: mkdir /opt/data
[root@zyq mysql]#: mysqld --initialize --user=mysql --datadir=/opt/data/
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]#: echo 'n1O6QThtF;mu' > pass

配置my.cnf文件
[root@zyq mysql]#: vi /etc/my.cnf
[root@zyq mysql]#: cat /etc/my.cnf
[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]#: cd support-files/
[root@zyq support-files]#: file mysql.server 
mysql.server: POSIX shell script, ASCII text executable
[root@zyq support-files]#: mkdir /etc/init.d
[root@zyq support-files]#: cp -a mysql.server /etc/init.d/mysqld
[root@zyq support-files]#: ll /etc/init.d/mysqld 
-rwxr-xr-x. 1 mysql mysql 10576 Oct 12 21:47 /etc/init.d/mysqld
指名路径(安装路径,数据路径)
[root@zyq support-files]#: vi /etc/init.d/mysqld 
basedir=/use/local/mysql
datadir=/opt/data

启动
[root@zyq support-files]#: cd 
[root@zyq ~]#: systemctl daemon-reload 
[root@zyq ~]#: service mysqld start 
Starting MySQL.Logging to '/opt/data/zyq.err'.
 SUCCESS! 
[root@zyq ~]#: ss -antl
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 ~]#: service mysqld stop
Shutting down MySQL.. SUCCESS!

用配置文件方式启动,停止服务
[root@zyq ~]#: cd /usr/lib/systemd/system
[root@zyq system]#: cp sshd.service mysql.service
[root@zyq system]#: vi mysql.service 
[root@zyq system]#: cat mysql.service 
[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]#: systemctl daemon-reload 
[root@zyq system]#: cd
[root@zyq ~]#: systemctl status mysql.service 
○ mysql.service - mysqld server daemon
     Loaded: loaded (/usr/lib/systemd/system/mysql.service; disabled; vend>
     Active: inactive (dead)

[root@zyq ~]#: ss -antl
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 ~]#: systemctl start mysql.service 
[root@zyq ~]#: ss -antl
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 ~]#: systemctl status mysql.service 
● mysql.service - mysqld server daemon
     Loaded: loaded (/usr/lib/systemd/system/mysql.service; disabled; vend>
     Active: active (running) since Tue 2023-12-05 17:52:41 CST; 14s ago
    Process: 32503 ExecStart=service mysqld start (code=exited, status=0/S>
   Main PID: 32524 (mysqld_safe)
      Tasks: 39 (limit: 48715)
     Memory: 370.6M
        CPU: 520ms
     CGroup: /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 ~]#: systemctl enable mysql.service 
Created symlink /etc/systemd/system/multi-user.target.wants/mysql.service → /usr/lib/systemd/system/mysql.service.
[root@zyq ~]#: systemctl status mysql.service 
● mysql.service - mysqld server daemon
     Loaded: 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.6M
        CPU: 1.075s
     CGroup: /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 ~]#: reboot
[root@zyq ~]#: ss -antl
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               *:*  

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
  • 168
  • 169
  • 170
  • 171
  • 172
  • 173
  • 174
  • 175
  • 176
  • 177
  • 178
  • 179
  • 180
  • 181
  • 182
  • 183
  • 184
  • 185
  • 186
  • 187
  • 188
  • 189
  • 190
  • 191
设置数据库密码
使用初始化的密码登录
[root@zyq ~]#: mysql -uroot -p'n1O6QThtF;mu'

mysql> alter user 'root'@'localhost' identified with mysql_native_password by 'Pssword@_';

  • 1
  • 2
  • 3
  • 4
  • 5
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小小林熬夜学编程/article/detail/300581
推荐阅读
相关标签
  

闽ICP备14008679号