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
| cat > /etc/systemd/system/mysqld.service <<'EOF' [Unit] Description=MySQL Server After=network.target
[Service] User=mysql Group=mysql ExecStart=/usr/local/mysql/bin/mysqld --defaults-file=/etc/my.cnf ExecStop=/usr/local/mysql/bin/mysqladmin -uroot -p'' shutdown Restart=on-failure LimitNOFILE=65535
[Install] WantedBy=multi-user.target EOF [root@db01 /usr/local]# systemctl daemon-reload -------------------- [root@db01 /usr/local]# systemctl start mysqld [root@db01 /usr/local]# netstat -tnulp Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 909/sshd: /usr/sbin tcp 0 0 127.0.0.53:53 0.0.0.0:* LISTEN 837/systemd-resolve tcp6 0 0 :::22 :::* LISTEN 909/sshd: /usr/sbin tcp6 0 0 :::33060 :::* LISTEN 2323/mysqld tcp6 0 0 :::3306 :::* LISTEN 2323/mysqld udp 0 0 127.0.0.53:53 0.0.0.0:* 837/systemd-resolve [root@db01 /usr/local]# systemctl status mysqld ● mysqld.service - MySQL Server Loaded: loaded (/etc/systemd/system/mysqld.service; disabled; vendor preset: enabled) Active: active (running) since Thu 2026-03-19 19:32:57 CST; 10s ago Main PID: 2323 (mysqld) Tasks: 39 (limit: 4515) Memory: 460.4M CPU: 1.175s CGroup: /system.slice/mysqld.service └─2323 /usr/local/mysql/bin/mysqld --defaults-file=/etc/my.cnf
Mar 19 19:32:57 db01 systemd[1]: Started MySQL Server. ....... [root@db01 /usr/local]# systemctl stop mysqld [root@db01 /usr/local]# netstat -tnulp Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 909/sshd: /usr/sbin tcp 0 0 127.0.0.53:53 0.0.0.0:* LISTEN 837/systemd-resolve tcp6 0 0 :::22 :::* LISTEN 909/sshd: /usr/sbin udp 0 0 127.0.0.53:53 0.0.0.0:* 837/systemd-resolve
|