Linux安装mysql.8.0.12

时间:2023-12-11 20:07:38

1. linux安装mysql8.0.12,亲测可用。

以下是安装过程中出现的问题:

 1 [root@localtest1 file]# systemctl start mysqld
2 Job for mysqld.service failed because the control process exited with error code. See "systemctl status mysqld.service" and "journalctl -xe" for details.
3
4 [root@localtest1 file]# systemctl status mysqld
5 ● mysqld.service - MySQL Server
6 Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
7 Active: failed (Result: exit-code) since Tue 2018-09-11 19:58:27 CST; 15s ago
8 Docs: man:mysqld(8)
9 http://dev.mysql.com/doc/refman/en/using-systemd.html
10 Process: 29481 ExecStart=/usr/sbin/mysqld $MYSQLD_OPTS (code=exited, status=1/FAILURE)
11 Process: 29454 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
12 Main PID: 29481 (code=exited, status=1/FAILURE)
13 Status: "SERVER_BOOTING"
14 Error: 98 (Address already in use)
15
16 Sep 11 19:58:23 localtest1.guandata.com systemd[1]: Starting MySQL Server...
17 Sep 11 19:58:27 localtest1.guandata.com systemd[1]: mysqld.service: main process exited, code=exited, status=1/FAILURE
18 Sep 11 19:58:27 localtest1.guandata.com systemd[1]: Failed to start MySQL Server.
19 Sep 11 19:58:27 localtest1.guandata.com systemd[1]: Unit mysqld.service entered failed state.
20 Sep 11 19:58:27 localtest1.guandata.com systemd[1]: mysqld.service failed.
21 [root@localtest1 file]# lsof -i :3306
22 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
23 docker-pr 17413 root 4u IPv6 23187758 0t0 TCP *:mysql (LISTEN)
24
25 原因:docker中已使用mysql并占用3306端口。由于我是测试自己的项目,就改了自己的mysql的端口号,重新装了一个mysql。
修改mysql端口号:
[root@localtest1 file]# vi /etc/my.cnf
增加行:
port=7566

2. 安装过程中会用到的linux命令

 启动mysqld服务
systemctl start mysqld 查看mysqld状态
systemctl status mysqld 查看mysql日志
tail -n 100 /var/log/mysqld.log 列出谁在使用某个端口(https://www.cnblogs.com/sparkbj/p/7161669.html)
lsof -i :7566 netstat命令用来打印Linux中网络系统的状态信息
netstat -anp|grep 0715

3. MySQL.8.0.12密码修改策略