Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to configure the boot self-startup of MySQL5.7 on centos7

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly shows you "how to configure MySQL5.7 boot on centos7", the content is easy to understand, clear, hope to help you solve your doubts, the following let Xiaobian lead you to study and learn "how to configure MySQL5.7 boot self-boot on centos7" this article.

Centos7 began to change the way the / etc/init.d startup scripts of previous system services were changed, and all the management of services in centos7 was centralized in systemctl.

Systemctl is a collection of system management daemons, tools, and libraries that replace previous System V, service, and chkconfig commands.

Create a configuration file to start MySQL

[root@localhost ~] # touch / usr/lib/systemd/system/mysqld.service

[root@localhost ~] # cd / usr/lib/systemd/system

Edit the mysqld.service file and add the following:

[root@localhost system] # vi mysqld.service

[Unit]

Description=MySQL Server

Documentation=man:mysqld (8)

Documentation= http://dev.mysql.com/doc/refman/en/using-systemd.html

After=network.target

After=syslog.target

[Install]

WantedBy=multi-user.target

[Service]

User=mysql

Group=mysql

ExecStart=/opt/mysql-5.7.18/bin/mysqld-defaults-file=/etc/my.cnf

LimitNOFILE = 5000

Save exit

Note: ExecStart=/opt/mysql-5.7.18/bin/mysqld (here, please change to the path where the MySQL program is located)

Find the mysqld path, for example:

[root@localhost system] # which mysqld

/ opt/mysql-5.7.18/bin/mysqld

Start mysql5.7 by systemctl:

[root@localhost system] # systemctl start mysqld

Check the MySQL operational status:

[root@localhost system] # mysql-p

Enter password:

Welcome to the MySQL monitor. Commands end with; or\ g.

Your MySQL connection id is 6

Server version: 5.7.18-log MySQL Community Server (GPL)

Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.

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 >

Mysql >

Mysql >\ s

-

Mysql Ver 14.14 Distrib 5.7.18, for linux-glibc2.5 (x86 / 64) using EditLine wrapper

Connection id: 6

Current database:

Current user: root@localhost

SSL: Not in use

Current pager: stdout

Using outfile:''

Using delimiter:

Server version: 5.7.18-log MySQL Community Server (GPL)

Protocol version: 10

Connection: Localhost via UNIX socket

Server characterset: latin1

Db characterset: latin1

Client characterset: utf8

Conn. Characterset: utf8

UNIX socket: / tmp/mysql.sock

Uptime: 45 sec

Threads: 3 Questions: 6 Slow queries: 0 Opens: 108 Flush tables: 1 Open tables: 101 Queries per second avg: 0.133

-

Mysql >

Turn off the firewall:

[root@localhost system] # systemctl stop firewalld.service

[root@localhost system] # systemctl disable firewalld.service

Removed symlink / etc/systemd/system/multi-user.target.wants/firewalld.service.

Removed symlink / etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.

Set the boot of mysql:

[root@localhost system] # systemctl enable mysqld

Created symlink from / etc/systemd/system/multi-user.target.wants/mysqld.service to / usr/lib/systemd/system/mysqld.service.

[root@localhost system] # systemctl list-unit-files | grep mysqld

Mysqld.service enabled

Cancel the boot self-boot of mysql:

[root@localhost system] # systemctl disable mysqld

Removed symlink / etc/systemd/system/multi-user.target.wants/mysqld.service.

[root@localhost system] # systemctl list-unit-files | grep mysqld

Mysqld.service disabled

The above is all the contents of the article "how to configure MySQL5.7 on centos7 to boot". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report