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

The method of installing mysql in binary system of centos7 system

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

Share

Shulou(Shulou.com)06/01 Report--

The following mainly brings you the method of installing mysql in binary system of centos7 system. I hope these contents can bring you practical use, which is also the main purpose of this article that I edit the method of installing mysql in binary system of centos7 system. All right, don't talk too much nonsense, let's just read the following.

Step 1: first download the mariadb compiled binary package from mariadb's official website.

Https://downloads.mariadb.org/

Step 2: extract the downloaded mariadb package, because the download is a good binary package compiled by others, so the decompression path must be under "/ usr/local/". If you compile your own source code, you can choose to extract the directory!

Tar xvf mariadb-102.23-linux-x86_64.tar.gz-C / usr/local/

Step 3: since the extracted folder (mariadb-10.2.23-linux-x86_64) is different from the compiled folder name (mysql), we need to change the folder name or create a soft link. Here I recommend creating a soft link, which is more convenient for future versions.

Cd / usr/local/ (enter / usr/local/ directory) ln-s mariadb-10.2.23-linux-x86_64/ mysql (create a soft link for mariadb-10.2.23-linux-x86_64 named mysql)

Step 4: look at the mysql folder and find that the owners and groups of all the files under this folder belong to errors, and their characteristics are more than 1000, so we need to change all files in this folder as well as the owners and groups of the folder to root.

Ll mysql/ (View all files and folders properties under mysql) chown-R root.root mysql/ (modify the owner and group of all files and folders under mysql to root)

Step 5: since mysql needs a mysql-specific user, but we compile and install, we need to create a mysql user ourselves

Mkdir / data/mysql (create a folder called mysql under / data) groupadd-r-g 336 mysql (create a group named mysql with permission 336) useradd-r-g mysql-u336-s / sbin/nologin-d / data/mysql mysql

Create a user with permission 336, named mysql, primary group mysql, and home directory / data/mysql mysql. Note: because the home directory is to store data, I suggest that the home directory be set as a logical volume for easy management! )

Chown-R mysql.mysql / data/mysql (change the owner and group of the / data/mysql folder to mysql)

Step 6: because we are a binary installation, there are no data files needed for the database in the mysql folder, but there is a mysql_install_db j script under the extracted mysql/scripts/ folder that can help us configure the data files needed by the database.

Scripts/mysql_install_db-- user=mysql-- datadir=/data/mysql (run the mysql_install_db script as mysql to generate database files to / data/mysql

Step 7: since we are a binary installation, we need to build a special configuration file to let mysql know that the path to its data file is here in / data/mysql

Mkdir / etc/mysql/ (create a mysql folder under etc)

Cp support-files/my-huge.cnf / etc/mysql/my.cnf (copy the configuration file format to / etc/mysql/my.cnf) vim / etc/mysql/my.cnf (change the configuration, add datadir=/data/mysql in line 28 of the configuration and specify the database default path to / data/mysql)

Step 8: finally, all that is needed is a service script, which also has a mysql.server script under the extracted mysql/support-files/. Just copy this script to the specified folder / etc/init.d/mysqld.

Cp support-files/mysql.server / etc/init.d/mysqld (copy mysql.server to / etc/init.d/mysqld) chkconfig-- add mysqld (add mysql to the service) echo PATH= `/ usr/local/mysql/bin:$PATH' > / etc/profile.d/mysql.sh (write the mysqlPATH path to the configuration file permanently) service mysqld start` (start the mysql service)

Step 9: since the newly configured mysql can be logged in to any anonymous account, we need to do one last security hardening on mysql, set a password and delete the anonymous account login option!

Systemctl set-default multi- user.target` (the first step is to set the mysql password, and then y will be fine)

For the above on the centos7 system binary installation of mysql, we do not think it is very helpful. If you need to know more, please continue to follow our industry information. I'm sure you'll like it.

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