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 the mysql-5.7.22 source code is installed

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

Share

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

The following content mainly brings you how the mysql-5.7.22 source code is installed, the knowledge mentioned here, which is slightly different from books, is summed up by professional and technical personnel in the process of contact with users, with a certain value of experience sharing, hoping to bring help to the majority of readers.

Cat / etc/redhat-release # View system version

CentOS Linux release 7.3.1611 (Core)

Uname-I # View the number of system digits

X86_64

Uname-r # View the system kernel

3.10.0-514.el7.x86_64

CentOS 7.0 uses firewall as the firewall by default

Turn off firewall:

Systemctl stop firewalld.service # stop firewall

Systemctl disable firewalld # prevents firewall from booting

Turn off selinux:

Vim / etc/sysconfig/selinux

Change to SELINUX=disabled

Set setenforce 0 # to make the configuration take effect immediately

1. If you must install mysql on centos 7, you need to uninstall MariaDB, otherwise there will be conflicts.

2. Execute this command: rpm-qa | grep mariadb

Rpm-e mariadb-libs-5.5.44-2.el7.centos.x86_64-- nodeps

1. Install cmake

Cmake: since the regular configure compilation method has been deprecated from the MySQL5.5 version, a CMake compiler is required to set the compilation parameters for mysql. Such as: installation directory, data storage directory, character encoding, sorting rules and so on.

2. Install the dependency package

Yum-y install gcc gcc-c++ make cmake autoconf automake ncurses-devel bison zlib libgcrypt libtool bison

Boost: starting from MySQL 5.7.5, the Boost library is required. C++ 's Boost library is used in the mysql source code, and boost1.59.0 or above is required.

C _ syntax + parser under bison:Linux

Ncurses: character terminal processing library

Download Boost_1_59_0.tar.gz

Wget http://nchc.dl.sourceforge.net/project/boost/boost/1.59.0/boost_1_59_0.tar.gz

Mkdir-p / usr/local/boost/

Tar-zxvf boost_1_59_0.tar.gz-C / usr/local/boost/

Download mysql-5.7.22.tar.gz

Https://dev.mysql.com/downloads/file/?id=476979

Start installing mysql

Groupadd mysql

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

Or

Useradd-U mysql-M-s / sbin/nologin #-U: create a group with the same name as the user and add the user to the group

Id mysql # View

Tar-zxvf mysql-5.7.22.tar.gz # decompression

Cd mysql-5.7.22 # enter the directory

Cmake\

-DCMAKE_INSTALL_PREFIX=/usr/local/mysql-5.7.22\ # install base directory. This value can be set using this-- basedir option when the CVM starts.

-DMYSQL_DATADIR=/usr/local/mysql-5.7.22/data\ # location of the MySQL data directory this value can be set using the-- datadir option when the server starts

-DMYSQL_UNIX_ADDR=/usr/local/mysql-5.7.22/tmp/mysql.sock\ # socket file path, default / tmp/mysql.sock this value can be set using this-- socket option when the server starts

-DDEFAULT_CHARSET=utf8\ # specifies the server default character set, default latin1

-DDEFAULT_COLLATION=utf8_general_ci\ specifies the default proofreading rules for the server, and the default latin1_general_ci

-DWITH_EXTRA_CHARSETS=all\ # what additional character sets to include: all: all character sets. This is the default setting complex: complex character set none: no additional character set

-DENABLED_LOCAL_INFILE=1\ # enable loading of local data. Default is OFF

-DWITH_BOOST=/usr/local/boost # boost library address

Compile

Mysql-5.7.22.tar.gz will take up a lot of system resources when compiling. It is recommended to use multiple cores to compile at the same time, otherwise the compilation may fail.

# check the number of server cpu

Grep processor / proc/cpuinfo | wc-l

two

Make-j 2

Echo $? # 0 means there is nothing wrong

Installation

Make install

Echo $? # 0 means there is nothing wrong

Ln-s / usr/local/mysql-5.7.22 / usr/local/mysql # do soft connection

Ls-l / usr/local/mysql # View soft connections

Lrwxrwxrwx. 1 root root 23 Jul 9 16:01 / usr/local/mysql- > / usr/local/mysql-5.7.22

Mkdir-p / usr/local/mysql/data/ # database storage directory

Mkdir-p / usr/local/mysql/tmp/ # mysql.sock directory

Mkdir-p / usr/local/mysql/log/ # error log directory

Mkdir-p / usr/local/mysql/run/ # mysql.pid generate and store directory

Mkdir-p / usr/local/mysql/log/binlog/ # mysql binary log generation directory

Chown-R mysql:mysql / usr/local/mysql/ # authorizes to change the mysql installation directory to belong to and group to mysql users

Initialize the database

/ usr/local/mysql/bin/mysqld-user=mysql-initialize-insecure-basedir=/usr/local/mysql/-datadir=/usr/local/mysql/data/

Production mysql system database

-- initialize means the password is generated by default,-- initialize-insecure means no password is generated, and the password is empty.

Centos6 operation:

Cp / usr/local/mysql/support-files/mysql.server / etc/rc.d/init.d/mysqld # add Mysql to the system startup

Chmod 755 / etc/init.d/mysqld

Add self-boot

Centos7.3 cannot be added to boot by using chkconfig

Append Mysql startup service to / etc/rc.local

Echo "/ etc/init.d/mysqld start" > > / etc/rc.local

Centos7 operation:

Cp / usr/local/mysql/support-files/mysql.server / usr/lib/systemd/system/mysqld.service # add Mysql to the system startup

Modify vim mysqld.service

# description of the service

[Unit]

# describe the service

Description=Mysql server

# After is started after that service, usually after the network service is started

After=network.target

# Settings of service operation parameters

[Service]

User=mysql

Group=mysql

# how to run in the background

Type=forking

# specific running commands of the service

ExecStart=/usr/local/mysql/support-files/mysql.server start

# ExecStart=/usr/local/mysql/bin/mysqld-defaults-file=/etc/my.cnf

[Install]

WantedBy=multi-user.target

Add self-boot

Systemctl enable mysqld

View

Systemctl list-unit-files | grep mysqld

Mysqld.service enabled

Change the configuration file

Vi / etc/my.cnf

[mysqld]

User=mysql

Port=3306

Datadir=/usr/local/mysql/data

Socket=/usr/local/mysql/tmp/mysql.sock

Basedir=/usr/local/mysql

Log-error=/usr/local/mysql/log/mysql_err.log # error log file path

Pid-file=/usr/local/mysql/run/mysql.pid

# disable hostname resolution

Skip-name-resolve

# default database engine

Default-storage-engine=InnoDB

# case insensitive

Lower_case_table_names= 1

# enable binlog log function

Server-id=1

Log-bin=/usr/local/mysql/log/binlog/mysql57-bin

Relay-log=/usr/local/mysql/log/binlog/mysql57-relay-bin

Binlog-cache-size= 4m # sets the binary log cache size

Max_binlog_cache_size= 8m # maximum binary Cache log buffer size

Max_binlog_size= 1G # maximum value of a single binary log file, default 1G, maximum 1G

Sync-binlog= 1 # writes the binary log records in the cache back to disk every N seconds

Binlog_format= mixed # binary log format (mixed (mixed, row (line), statement))

Expire_logs_days= 30 # binary log file expiration time

Back_log= 50 # indicates how many requests in a short period of time before MySQL temporarily stops responding to new requests. The default is 50

The maximum number of files that open_files_limit= 65535 # Mysql can open

Max_connections= 1000 # specifies the maximum number of connection processes allowed by Mysql

Max_connect_errors= 1000 # sets the maximum number of connection requests for each host that are abnormally interrupted

The value of the largest query packet that can be processed by the max_allowed_packet= 16m # server at a time

Wait_timeout= 120 # specify the maximum connection time for a request

Interactive_timeout = 8 # how long the connection stays active

Thread_stack= 192 k # sets the heap size of each thread of Mysql. The default value is large enough to satisfy ordinary user operations.

Max_binlog_size= 1G # maximum value of a single binary log file, default 1G, maximum 1G

Sync-binlog= 1 # writes the binary log records in the cache back to disk every N seconds

Binlog_format= mixed # binary log format (mixed (mixed, row (line), statement))

Expire_logs_days= 30 # binary log file expiration time

Back_log= 50 # indicates how many requests in a short period of time before MySQL temporarily stops responding to new requests. The default is 50

The maximum number of files that open_files_limit= 65535 # Mysql can open

Max_connections= 1000 # specifies the maximum number of connection processes allowed by Mysql

Max_connect_errors= 1000 # sets the maximum number of connection requests for each host that are abnormally interrupted

The value of the largest query packet that can be processed by the max_allowed_packet= 16m # server at a time

Wait_timeout= 28800 # specify the maximum connection time for a request

Interactive_timeout = 28800 # how long the connection stays active

Thread_stack= 192 k # sets the heap size of each thread of Mysql. The default value is large enough to satisfy ordinary user operations.

Slow_query_log=on # enable slow query

Long_query_time= 2 # specifies how many seconds a query that does not return a result is a slow query

Slow_query_log_file= / usr/local/mysql/log/mysql57-slow.log # specifies the path to the slow log file

Log-queries-not-using-indexes # records all queries that do not use the index

Min_examined_row_limit= 1000 # records slow queries caused by more than 1000 queries

Log-slow-admin-statements # record slow OPTIMIZE TABLE,ANALYZE TABLE and ALTER

Key_buffer_size= 32m # specifies the size of the buffer used for indexing, increasing it for better index processing performance

Sort_buffer_size= 2m # sets the buffer size that can be used when sorting queries. The default size is 2MB.

Buffer size that can be used by join_buffer_size= 2m # federated query operations

Buffer size that can be used by read_buffer_size= 4m # read query operation

Read_rnd_buffer_size= 16m # sets the buffer used for random reads

Bulk_insert_buffer_size= 8m # if you use special statements for batch insertion to insert data, you can adjust the parameters to 16MB-32MB appropriately. It is recommended that 8MB

Table_open_cache= 512 # sets the number of cache tables

Tmp_table_size= 64m # sets the maximum value of memory temporary table

Max_heap_table_size= 64m # maximum capacity allowed by stand-alone memory tables

Query_cache_size= 32m # specifies the size of the Mysql query buffer

Query_cache_limit= 2m # only results that are less than this setting will be cached

Query_cache_min_res_unit= 2k # sets the minimum unit of memory allocated by the query cache

Centos6 starts Mysql

/ etc/init.d/mysqld start

Starting MySQL.. SUCCESS!

Centos7 starts Mysql

Systemctl start mysqld.service

View the process

Ps-ef | grep mysql

Root 1712 10 09:50 pts/0 00:00:00 / bin/sh / usr/local/mysql/bin/mysqld_safe-- datadir=/usr/local/mysql/data-- pid-file=/usr/local/mysql/run/mysql.pid

Mysql 2350 1712 20 09:50 pts/0 00:00:00 / usr/local/mysql/bin/mysqld-basedir=/usr/local/mysql-datadir=/usr/local/mysql/data-plugin-dir=/usr/local/mysql/lib/plugin-user=mysql-log-error=/usr/local/mysql/log/mysql_err.log-open-files-limit=65535-pid-file=/usr/local/mysql/run/mysql.pid-socket=/usr/local/mysql/tmp/mysql.sock-port=3306

Root 2382 1662 0 09:50 pts/0 00:00:00 grep-color=auto mysql

View Port

Netstat-tlunp | grep mysql

Tcp6 0 0: 3306: * LISTEN 2350/mysqld

View connected

Netstat-an | grep EST

Tcp 0 96 10.10.16.252 ssh 22 10.10.16.10 ssh 50954 client establish a connection

Add mysql to the system environment variable: add it on the last line

Vi / etc/profile

Export PATH= "/ usr/local/mysql/bin/:$PATH"

Source / etc/profile # makes the configuration effective immediately

Log in to mysql

Mysql

The first way to change the password

Set password for 'root'@'localhost'=Password (' mysql57')

Quit # exit

Mysql-uroot-p # sign in again

Mysql57

The second way to change the password

Grant all on. To 'root'@'localhost' identified by' mysql123'

Flush privileges

Set up remote connections to other hosts

Grant all on. To 'root'@'%' identified by' password

Flush privileges

Another way

Use mysql

Update user set Host= "" where User= "root" limit 1

Flush privileges

For the above about how to install the mysql-5.7.22 source code, if you need to know more, you can continue to pay attention to the innovation of our industry. If you need professional answers, you can contact the pre-sales and after-sales on the official website. I hope this article can bring you some knowledge updates.

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