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 mysql5.7.16 with source code in centos7 environment

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

Share

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

This article mainly introduces the centos7 environment source code how to install mysql5.7.16, the article introduces in great detail, has a certain reference value, interested friends must read!

This paper gives an example of how to install mysql5.7.16 with source code in centos7 environment. Share with you for your reference, the details are as follows:

First, download the source package

Download the mysql source code package

Http://mirrors.sohu.com/mysql/MySQL-5.7/mysql-5.7.16.tar.gz

Second, the installation agreement:

User name: mysql

Installation directory: / data/mysql

Database directory: / data/mysql/data

Third, installation preparation

1. Add users

> useradd-s / sbin/nologin mysql

2. Set up a directory

> mkdir / data/mysql

3. Change the owner and owner of the directory

> chown-R mysql:mysql / data/mysql

4. Install and edit the required files

> yum install gcc gcc-c++ cmake bison-devel ncurses-devel libaio libaio-devel

(* boost is required for mysql5.7.5 and above)

> yum install boost boost-devel

5. Decompress the source package

> tar-xf mysql-5.7.16.tar.gz

IV. Compilation and installation

> cd / data/mysql-5.7.16 > cmake\-DMYSQL_USER=mysql\-DCMAKE_INSTALL_PREFIX=/data/mysql\-DMYSQL_DATADIR=/data/mysql/data\-DSYSCONFDIR=/data/mysql\-DWITH_MYISAM_STORAGE_ENGINE=1\-DWITH_INNOBASE_STORAGE_ENGINE=1\-DWITH_MEMORY_STORAGE_ENGINE=1\-DINSTALL_PLUGINDIR=/data/mysql/plugin\-DWITH_READLINE=1\-DMYSQL_UNIX_ADDR=/data/mysql/mysql.sock\-DMYSQL_TCP_PORT=3306\-DENABLED_LOCAL_INFILE=1\ -DWITH_PARTITION_STORAGE_ENGINE=1\-DEXTRA_CHARSETS=all\-DDEFAULT_CHARSET=utf8\-DDEFAULT_COLLATION=utf8_general_ci\-DDOWNLOAD_BOOST=1\-DWITH_BOOST=/usr/local/boost

(* Note: if an error occurs, delete the CMakeCache.txt and rerun the configuration)

The above parameters are explained as follows:

# mysql user name-DMYSQL_USER=mysql# installation path-location of DCMAKE_INSTALL_PREFIX=/data/mysql# data files-DMYSQL_DATADIR=/data/mysql/data#my.cnf path-DSYSCONFDIR=/data/mysql# support MyIASM engine-DWITH_MYISAM_STORAGE_ENGINE=1# support InnoDB engine-DWITH_INNOBASE_STORAGE_ENGINE=1# support Memory engine-DWITH_MEMORY_STORAGE_ENGINE=1# plug-in file and configuration path-DINSTALL_PLUGINDIR=/data/mysql/plugin# shortcut Key function (I have not used it)-DWITH_READLINE=1# connection database socket path-DMYSQL_UNIX_ADDR=/data/mysql/mysql.sock# port-DMYSQL_TCP_PORT=3306# allows local import of data-DENABLED_LOCAL_INFILE=1# installation supports database partitions-DWITH_PARTITION_STORAGE_ENGINE=1# installs all character sets-DEXTRA_CHARSETS=all# default characters-DDEFAULT_CHARSET=utf8# check characters-DDEFAULT_COLLATION=utf8_general_ci# will download automatically Boost-DDOWNLOAD_BOOST=1# specifies the boost directory-DWITH_BOOST=/usr/local/boost

Compilation and installation

> make & & make install

Copy Profil

> cp / data/mysql/support-files/my-default.cnf / data/mysql/my.cnf

Initialize the database

> / data/mysql/bin/mysqld\-defaults-file=/data/mysql/my.cnf\-initialize\-user=mysql\-basedir=/data/mysql\-datadir=/data/mysql/data\

If the following message appears:

Unknown variable 'defaults-file=/data/mysql/my.cnf'

Make sure-- the defaults-file configuration option is at the top.

If the following message appears:

[ERROR]-initialize specified but the data directory has files in it. Aborting.

Please make sure that your datadir directory is empty and delete if there are any files.

Mysql5.7 version through-- initialize installation will randomly generate a root password, please pay attention to save.

If you want to generate an empty password, use the-- initialize-insecure configuration.

Modify the owner of the mysql directory

> chown-R mysql:mysql / data/mysql

5. Configure mysql configuration file my.cnf

Since we set its configuration file directory to / data/mysql when we compiled and installed mysql, delete / etc/my.cnf.

So as not to be affected.

> rm-rf / etc/my.cnf > vi / data/mysql/my.cnf

The configuration is as follows:

[client] default-character-set = utf8port = 3306socket = / data/mysql/ MySQL. Socks [MySQL] default-character-set = utf8 [mysqld] skip-name-resolvebasedir = / data/mysqldatadir = / data/mysql/dataport = 3306server_id = 10socket = / data/mysql/mysql.sockcharacter-set-server = utf8max_connections = 200default-storage-engine = INNODBlog-bin=mysql-bin

Add boot boot for mysql

> cp / data/mysql/support-files/mysql.server / etc/init.d/mysqld > chmod 755 / etc/init.d/mysqld > chkconfig-- add mysqld

Start the mysql service

> service mysqld start

Add environment variables for mysql

> echo "export PATH=/data/mysql/bin/:$PATH" > > / etc/profile > source / etc/profile

Change the root password by logging in to mysql with the password saved above

> mysql-uroot-p > set password=password ('123456'); > alter user' root'@'localhost' password expire never; > flush privileges; are all the contents of this article entitled "how to install mysql5.7.16 with source code in centos7 environment". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to 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