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 write the shell script for installing MySQL in the source code package in Linux

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

This article is to share with you about Linux source package installation MySQL shell script how to write, the editor feels very practical, so share with you to learn, I hope you can get something after reading this article, say no more, follow the editor to have a look.

#! / bin/bash

# install MYSQL

Yum-y install ncurses-devel

Yum-y install autoconf

Tar zxf / cmake--C /

Cd / cmake-

. / configure & & gmake & & gmake install

Cd

Groupadd mysql

Useradd-M-s / sbin/nologin/ mysql-g mysql

Tar zxf / mysql--C / usr/src

Cd / usr/src/mysql-

Cmake-DCMAKE_INSTALL_PREFIX=/usr/local/mysql-DSYSCONFDIR=/etc/-DDEFAULT_CHARSET=utf8-DDEFAULT_COLLATION=utf8_general_ci-DWITH_EXTRA_CHARSETS=all

Make & & make install

Chown-R mysql:mysql / usr/local/mysql

Rm-rf / etc/my.cnf

Cp support-files/my-default.cnf / etc/my.cnf

/ usr/local/mysql/scripts/mysql_install_db-user=mysql-basedir=/usr/local/mysql-datadir=/usr/local/mysql/data

Echo "PATH=$PATH:/usr/local/mysql/bin" > > / etc/profile

. / etc/profile

Cp support-files/mysql.server / usr/local/mysql/bin/mysqld.sh

Chmod + x / usr/local/mysql/bin/mysqld.sh

Echo "[Unit]" > > / usr/lib/systemd/system/mysqld.service

Echo "Description=MYSQL Server" > > / usr/lib/systemd/system/mysqld.service

Echo "After=network.target" > > / usr/lib/systemd/system/mysqld.service

Echo "[Service]" > > / usr/lib/systemd/system/mysqld.service

Echo "User=mysql" > > / usr/lib/systemd/system/mysqld.service

Echo "Group=mysql" > > / usr/lib/systemd/system/mysqld.service

Echo "Type=forking" > > / usr/lib/systemd/system/mysqld.service

Echo "PIDFile=/usr/local/mysql/data/localhost.localdomain.pid" > > / usr/lib/systemd/system/mysqld.service

Echo "ExecStart=/usr/local/mysql/bin/mysqld.sh start" > > / usr/lib/systemd/system/mysqld.service

Echo "ExecStop=/usr/local/mysql/bin/mysqld.sh stop" > > / usr/lib/systemd/system/mysqld.service

Echo "[Install]" > > / usr/lib/systemd/system/mysqld.service

Echo "WantedBy=multi-user.target" > > / usr/lib/systemd/system/mysqld.service

Systemctl daemon-reload

Systemctl start mysqld

Systemctl enable mysqld

. / etc/profile

The above is how to write the shell script for installing MySQL in the source code package in Linux. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please 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