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 install Mysql and set up boot self-boot for CentOS7

2025-04-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article mainly introduces "how to install Mysql in CentOS7 and set up boot self-startup". In daily operation, I believe many people have doubts about how to install Mysql and set up boot self-startup in CentOS7. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the questions of "how to install Mysql and set up boot self-startup in CentOS7". Next, please follow the editor to study!

Centos 7 no longer comes with the mysql database, and the default database is mariadb, a branch of mysql.

You can install the mysql database manually by following these steps.

1. Download the rpm installation file

Wget http://repo.mysql.com/mysql-community-release-el7.rpm

two。 Perform rpm installation

Rpm-ivh mysql-community-release-el7.rpm

When the dependency resolution is complete, the following options appear:

Dependencies resolved= package arch version repository size=installing: mysql-community-libs x86'64 5.6.32-2.el7 mysql56-community 2.0m replacing mariadb-libs.x86_64 1 replacing mariadb-libs.x86_64 5.47-1.el7_2 mysql-community-server x86'64 5.6.32-2.el7 mysql56-community 59 m installing for dependencies: mysql-community-client x86'64 5.6.32-2.el7 mysql56-community 19 m mysql-community-common x86 "64 5.6.32-2.el7 mysql56-community 256k perl-compress-raw-bzip2 x86" 64 2.061-3.el7 base 32k perl-compress-raw-zlib x86 "64 1purl 2.061-4.el7 base 57k perl-dbi x86 _ 64 1.627-4.el7 base 802k perl-io-compress noarch 2.061-2.el7 base 260k perl-net-daemon noarch 0.48-5.el7 base 51k perl-plrpc noarch 0.2020-14.el7 base 36 ktransaction summary=install 2 packages (+ 8 dependent packages) total download size: 82 mis this ok [y/d/n]:

3. As you can see, both server and client are chosen to be installed. Select y to download and install automatically.

4. After the installation is complete, start mysql.

Systemctl start mysqld.service

5. Set the root password.

Update user set password=password ("123456") where user='root'

6. Boot self-starting.

Vim / etc/rc.local add service mysqld start

7. Important updates:

The new rpm installation file does not have a script for automatic yum installation, so you need to perform the yum installation manually.

That is, you can execute yum install mysql-server after step 2.

8. About self-startup

Step 6 applies only if mysqld is not self-booting.

If the default mysql is self-starting, it may be out of order and other problems with the self-startup in rc.local.

A more secure solution can be found in:

The problem of self-starting of centos 7 Program

First, the problem phenomenon:

After the system restarts, it is found that the mysqld service starts normally, but the application a that relies on the mysql database fails to start.

Viewing the log shows that program a failed to link to the database when it started.

Second, reason analysis:

The mysqld service starts normally.

At this time, the manual restart program amaine an is also running normally.

Conclusion: mysqld may not be started when program a starts.

III. Startup sequence

The first thing that comes to mind is to adjust the startup order of the mysqld service so that it is higher than my program a.

However, it is found that there is no startup script for mysqld under the / etc/init.d path.

IV. Ideas for solution

Follow the link to indicate that the installed mysqld starts automatically by default.

You can cancel the self-startup of mysqld and then write a startup script to make sure it starts before program a starts.

V. Solutions

1. The way to view the system's current default startup project is no longer setup or the like.

Systemctl list-unit-files

Execute this command to view the service startup and service status of the current system.

The results are as follows:

... Microcode.service enabled mysql.service enabled mysqld.service enabled networkmanager-dispatcher.service enabled...

two。 Cancel the self-startup of mysqld

Systemctl disable mysqld

Check the service status of the current system after executing the command:

... Microcode.service enabled mysqld.service disabled networkmanager-dispatcher.service enabled...

3. Custom / etc/rc.local

Execute systemctl start mysqld first

Execute starta again

At this point, the study on "how to install Mysql in CentOS7 and set it to boot" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

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

Development

Wechat

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

12
Report