Compiling and installing MySQL database

Source: Internet
Author: User

Brief introduction

MySQL is an open-source relational database management system (RDBMS), which uses the most common database management language-Structured Query Language (SQL) for database management. The MySQL relational database released its first version in January 1998. It uses the multithreaded mechanism provided by the system core to provide a full multithreaded operation mode, providing programming interfaces (APIs) for C, C + +, Eiffel, Java, Perl, PHP, Python, and Tcl programming languages. Supports multiple field types and provides full operator support for select and where operations in queries.

Experimental environment

System Environment: CentOS 7

Host IP Address: 192.168.100.201

Yum Mount directory:/mnt/sr0

Related Source Package Link: Https://pan.baidu.com/s/1f3v-qM-vwK-nT-EKEScZkQ Password: t927

MYSQL-5.7.17.TAR.GZ software package installation directory space minimum of not less than 8G, or make completed will not be enough alarm space!

Experimental objectives

Build MySQL Database base service

Experimental steps

1. Install the Environment pack

Yum-y install \
ncurses \ #提供字符终端处理库
Ncurses-devel \ #字符终端下屏幕控制的基本库
Bison \ #gcc gcc-c++ Parser
CMake #跨平台的安装工具

2. Source code compilation and installation

(1) Create a running account

Useradd-s/sbin/nologin MySQL
(2) Unpacking
Tar zxvf mysql-5.7.17.tar.gz-c/opt/
Tar zxvf boost_1_59_0.tar.gz-c/usr/local/#c + + runtime
cd/usr/local/#需要指向的路径 for easy identification
MV Boost_1_59_0 Boost #重命名

(3) configuration
CD mysql-5.7.17/

 cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \         #安装目录-DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock \   #连接文件-DSYSCONFDIR=/etc \                        # mysql配置文件存在路径-DSYSTEMD_PID_DIR=/usr/local/mysql \         #进程文件所在路径-DDEFAULT_CHARSET=utf8  \                    #字符集-DDEFAULT_COLLATION=utf8_general_ci -DWITH_INNOBASE_STORAGE_ENGINE=1 \          #存储引擎-DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \ -DWITH_PERFSCHEMA_STORAGE_ENGINE=1 -DMYSQL_DATADIR=/usr/local/mysql/data \ #数据库文件所在路径-DWITH_BOOST=/usr/local/boost \         #支持c++运行库-DWITH_SYSTEMD=1                      #使系统支持mysql

(4) Compile and install
Make && make install

Note: This process waits a long time, about 40 minutes or so, to have psychological preparation!
3. Post-Installation adjustments

(1) Setting permissions on the database directory
[Email protected] etc]# chown mysql:mysql/etc/my.cnf
[Email protected] etc]# Ls-l | grep "MY.CNF" #查看权限
-rw-r--r--. 1 mysql mysql 728 August 02:15 my.cnf #权限已改为mysql
Drwxr-xr-x. 2 root root 31 July 04:14 MY.CNF.D

(2) Setting up the configuration file
[email protected] mysql-5.5.24]# CP support-files/my-medium.cnf/etc/my.cnf #创建配置文件
[Email protected] mysql-5.5.24]# vim/etc/my.cn #修改配置文件

[Client] #客户端
Port = 3306
Default-character-set=utf8
Socket =/usr/local/mysql/mysql.sock

[MySQL] #服务端
Port = 3306
Default-character-set=utf8
Socket =/usr/local/mysql/mysql.sock

[Mysqld] #针对于服务本身而言进行设定
user = MySQL
Basedir =/usr/local/mysql
DataDir =/usr/local/mysql/data
Port = 3306
Character_set_server=utf8
Pid-file =/usr/local/mysql/mysqld.pid
Socket =/usr/local/mysql/mysql.sock
Server-id = 1

Sql_mode=no_engine_substitution,strict_trans_tables,no_auto_create_user,no_auto_value_on_zero,no_zero_in_date, No_zero_date,error_for_division_by_zero,pipes_as_concat,ansi_quotes

(3) Initializing the database
cd/usr/local/mysql/

bin/mysqld --initialize-insecure \           #生成数据库密码,为空--user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data

(4) Setting environment variables
Echo ' path=/usr/local/mysql/bin:/usr/local/mysql/lib: $PATH ' >>/etc/profile #环境变量文件
echo ' Export PATH ' >>/etc/profile #设置全局模式
Source/etc/profile #执行使其生效

4. Adding system Services

cp/usr/local/mysql/usr/lib/systemd/system/mysqld.service/usr/lib/systemd/system/#复制启动脚本
Systemctl Daemon-reload #刷新识别启动脚本
Systemctl Start mysqld #启动MySQL

NETSTAT-ANPT | grep 3306 #查看端口

Systemctl Enable Mysqld #添加开机自启动

mysqladmin-u root-p Password "abc123" #设置登陆密码
Mysql-uroot–p123 #登录mysql

5. Implementing Telnet
Grant all privileges in . to ' root ' @ '% ' identified by ' abc123 ' with GRANT option; #设置权限 for remote Login

Compiling and installing MySQL database

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.