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

Mysql Series II: Centos7.4 installation mysql5.7.2

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

Share

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

This article installs mysql5.7.28 source code for blog Mysql series II: Centos7.4

There are many ways to install mysql. Take Centos7 as an example, you can download the compiled binaries on the official website, and download the rpm package on the official website to install the yum install rpm package. In this article, we introduce the official website to download the source code for self-compilation and installation.

According to my Mysql series of blog content download source code, we began to install mysql source code, installation method I hope you read more from the official website document, absorb the essence, installation method and sequence is not unique, the following content for reference.

Basic environment:

Yum install-y ntp wget curl lrzsz vim sysstat iftop pcre pcre-devel openssl openssl-devel

Compile the installation environment:

Yum-y install wget gcc gcc-c++ cmake openssl-devel ncurses-devel zlib-devel

Download and decompress the official website:

Mysql-5.7.28.tar.gz and mysql-boost-5.7.28.tar.gzcd / data/app_install/package tar zxvf mysql-5.7.28.tar.gz mkdir mysql-boosttar zxvf mysql-boost-5.7.28.tar.gz-C mysql-boost

To create a mysql user:

Groupadd mysql useradd-g mysql-s / sbin/nologin-d / data/app_install/mysql_3306 mysql

Create mysql related directories:

Mkdir-p / data/logs/mysql_3306 log directory mkdir-p / data/app_install/mysql_3306 installation directory mkdir-p / data/app_install/mysql_3306/conf my.cnf configuration files directory mkdir-p / data/app_install/mysql_3306/tmp mysql.sock directory mkdir-p / data/data/data_mysql Database file directory

Compile configuration:

Cmake. -DCMAKE_INSTALL_PREFIX=/data/app_install/mysql_3306-DMYSQL_DATADIR=/data/data/data_mysql-DWITH_BOOST=/data/app_install/package/mysql-boost/mysql-5.7.28/boost/boost_1_59_0-DSYSCONFDIR=/data/app_install/mysql_3306/conf-DWITH_INNOBASE_STORAGE_ENGINE=1-DWITH_PARTITION_STORAGE_ENGINE=1-DWITH_FEDERATED_STORAGE_ENGINE=1-DWITH_BLACKHOLE_STORAGE_ENGINE=1-DWITH_MYISAM_STORAGE_ENGINE=1-DENABLED_LOCAL _ INFILE=1-DENABLE_DTRACE=0-DDEFAULT_CHARSET=utf8mb4-DDEFAULT_COLLATION=utf8mb4_general_ci-DWITH_EMBEDDED_SERVER=1

Compile:

Make

Installation:

Make install

Configuration file:

Cd / data/app_install/mysql_3306/confvim my.cnf [client] port = 3306socket = / data/app_install/mysql_3306/tmp/ mysql.sock [mysqld] port = 3306socket = / data/app_install/mysql_3306/tmp/mysql.sockbasedir = / data/app_install/mysql_3306datadir = / data/data/data_mysqlpid-file = / data/app_install/mysql_3306/mysql.piduser = mysqlbind-address = 0.0.0.0server-id = 1init-connect =' SET NAMES utf8mb4'character-set-server = utf8mb4back_log = 300max_connect_errors = 6000open_files_limit = 65535table_open_cache = 128max_allowed_packet = 4Mbinlog_cache_size = 1Mmax_heap_table_size = 8Mtmp_table_size = 16Mread_rnd_buffer_size = 8Mjoin_buffer_size = 8Mkey_buffer_size = 4Mthread_cache_size = 8query_cache_type = 1query_cache_size = 8Mquery_cache_limit = 2Mft_min_word_len = 4log_bin = mysql-binbinlog_format = Mixedexpire_logs_days = 30log_error = / data/logs/mysql_3306/mysqld-error.logslow_query_log = 1long_query_time = 1slow_query_log_file = / data/logs/mysql_3306/mysql-slow.logperformance_schema = 0explicit_defaults_for_timestampskip-external-lockingdefault_storage_engine = InnoDBinnodb_file_per_table = 1innodb_open_files = 500innodb_buffer_pool_size = 2048Minnodb_write_io_threads = 4innodb_read_io_threads = 4innodb_thread_concurrency = 0innodb_purge_threads = 1innodb_flush_log_at_trx_commit = 2innodb_log_buffer_size = 2Minnodb_log_file_size = 32Minnodb_log_files_in_group = 3innodb_max_dirty_pages_pct = 90innodb_lock_wait_timeout = 120default-time-zone ='+ 08:00'interactive_timeout = 28800wait_timeout = 86400sqlMurmode = NO_AUTO_CREATE_USER NO_ENGINE_ support [mysqld _ safe] log-error = / data/logs/mysql_3306/mysqld_safe-error.logpid-file = / data/app_install/mysql_3306/mysql.pid

Startup file:

Cp / data/app_install/mysql_3306/support-files/mysql.server / etc/init.d/mysqld

Permissions:

Chown-R mysql:mysql / data/app_install/mysql_3306/chown-R mysql:mysql / data/data/data_mysql/chown-R mysql:mysql / data/logs/mysql_3306/

Environment variables:

Mkdir / data/envcd / data/envvim mysql.envexport PATH=$PATH:/data/app_install/mysql_3306/binvim / etc/profilesource / data/env/mysql.env

Initialize the database:

-initialize indicates that a random secure password is generated by default.-initialize-insecure means that no password is generated. If you do not want to find and use a random password in the log, you can initialize it in the following way, and then set the password in the security initialization boot.

Mysqld-defaults-file=/data/app_install/mysql_3306/conf/my.cnf-user=mysql-initialize-insecure

Start mysql:

/ etc/init.d/mysqld start

If you encounter a log path that does not exist or a permission problem during startup, you can recreate it and grant mysql:mysql permission, and encounter a Starting MySQL. ERROR! The server quit without updating PID file (/ data/app_install/mysql_3306/mysql.pid). It is also a permission issue. Mysql:mysql permissions are required for all directory files involved except startup files.

Try to log in:

You can log in without a password

Secure initialization Boot:

When using this feature, the mysql process needs to be online, using the mysql_secure_installation command for secure initialization boot

After setting up, you can log in again with the new password.

Set the program to start itself:

Chkconfig-add mysqldchkconfig mysqld onservice mysqld startservice mysqld stopservice mysqld restart

In fact, Centos7 can already use systemd to manage and self-start the service, and mysql can also. For example, to install using the source code version, you need to add a compilation item-DWITH_SYSTEMD=1, configure a self-named file under the / etc/systemd/system/mysqld.service.d directory, and then describe the following according to the actual situation:

[Service] LimitNOFILE=* `max _ open_ files` * PIDFile=* `/ path/to/pid/ file` * Nice=* `nice _ level` * LimitCore=* `core _ file_ library` * Environment= "LD_PRELOAD=*` / path/to/malloc/ library` *" Environment= "TZ=* `time _ zone_sett ing` *"

Re-systemctl daemon-reload

It can be seen that the download source code installation on the official website supports chkconfig+service and systemd+systemctl for service configuration and management, which requires manual step-by-step practice, which is very helpful to understand the whole principle and process.

If the compiled binary downloaded from the official website is installed, you can use chkconfig+service and systemd+systemctl to configure and manage the service. If the rpm package downloaded from the official website is installed with yum, you can directly configure and manage the service with systemd+systemctl.

You can then package the installation process and compiled files into an automated installation script and install the mysql database with one click, saving you from having to manually configure the compilation from scratch each time.

We will talk about some simple and practical operation commands of mysql that are often used in actual combat in the next section.

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