MySQL-8.0 源码包方式安装

1)安装Mysql数据库

[[email protected] ~]# rpm -q mysql mysql-server
未安装软件包 mysql
未安装软件包 mysql-server
[[email protected] ~]# yum -y install ncurses-devel
[[email protected] ~]# rpm -q ncurses-devel
ncurses-devel-5.9-14.20130511.el7_4.x86_64

安装配置工具cmake

[[email protected] ~]# tar xf cmake-3.13.1.tar.gz -C /usr/src/
[[email protected] ~]# cd /usr/src/cmake-3.13.1/
[[email protected] cmake-3.13.1]# ./configure && gmake && gmake install

创建运行用户

[[email protected] ~]# useradd -M -s /sbin/nologin mysql

解包,配置,编译,安装

[[email protected] ~]# tar xf mysql-8.0.11.tar.gz -C /usr/src/
[[email protected] ~]# cd /usr/src/mysql-8.0.11/
[[email protected] mysql-5.7.24]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS=all -DSYSCONFDIR=/etc && make && make install

-DCMAKE_INSTALL_PREFIX=/usr/local/mysql     //数据库程序安装目录
-DDEFAULT_CHARSET=utf8                  //指定字符集编码
-DDEFAULT_COLLATION=utf8_general_ci         //默认的字符集校对规则,utf8_general_ci适用于utf-8字符集的通用规则
-DWITH_EXTRA_CHARSETS=all               //指定额外支持的字符集编码
-DSYSCONFDIR=/etc                       //指定配置文件存放目录

报错处理:

----------------------------------------------------------------------------------------------------------------------------
CMake Error at cmake/boost.cmake:81 (MESSAGE):
  You can download it with -DDOWNLOAD_BOOST=1 -DWITH_BOOST=<directory>

  This CMake script will look for boost in <directory>.  If it is not there,
  it will download and unpack it (in that directory) for you.

  If you are inside a firewall, you may need to use an http proxy:

  export http_proxy=http://example.com:80

Call Stack (most recent call first):
  cmake/boost.cmake:238 (COULD_NOT_FIND_BOOST)
  CMakeLists.txt:507 (INCLUDE)

-- Configuring incomplete, errors occurred!
See also "/usr/src/mysql-5.7.24/CMakeFiles/CMakeOutput.log".
See also "/usr/src/mysql-5.7.24/CMakeFiles/CMakeError.log".
----------------------------------------------------------------------------------------------------------------------------

解决办法是:
1.在/usr/local下创建一个名为boost的文件夹

[[email protected] ~]# mkdir /usr/local/boost

2.进入目录并下载boost

[[email protected] ~]# cd /usr/local/boost
[[email protected] boost]# wget https://sourceforge.net/projects/boost/files/boost/1.66.0/boost_1_66_0.tar.gz

3.解压boost

[[email protected] boost]# tar xf boost_1_66_0.tar.gz

4.继续cmake,添加上红色部分

[[email protected] mysql-5.7.24]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS=all -DSYSCONFDIR=/etc -DWITH_BOOST=/usr/local/boost && make && make install

2)安装后的调整
对数据库目录进行权限设置

[[email protected] ~]# cd /usr/local/mysql/
[[email protected] mysql]# chown -R mysql:mysql ./

建立配置文件(CentOS7系统默认支持MariaDB数据库,系统默认的/etc/my.cnf配置文件是MariaDB的配置文件 )

[[email protected] mysql]# vim /etc/my.cnf
[mysqld]
datadir=/usr/local/mysql/data
socket=/tmp/mysql.sock

[mysqld_safe]
log-error=/usr/local/mysql/data/mysql.log
pid-file=/usr/local/mysql/data/mysql.pid

3)初始化数据库

[[email protected] mysql]# ./bin/mysqld --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --initialize
2018-12-08T01:51:39.798903Z 1 [Note] A temporary password is generated for [email protected]: dskL0)8S3FGe

--basedir=/usr/local/mysql/         //指定安装目录(产品目录)
--datadir=/usr/local/mysql/data     //指定数据目录
--user=mysql                    //指定用户身份

4)设置环境变量

[[email protected] mysql-5.7.24]# echo "PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile
[[email protected] mysql-5.7.24]# . /etc/profile  =  source /etc/profile

5)添加系统服务
添加MySQL为系统服务,以便通过systemctl命令进行管理

[[email protected] mysql-5.7.24]# cp support-files/mysql.server /usr/local/mysql/bin/mysqld.sh
[[email protected] mysql-5.7.24]# chmod +x /usr/local/mysql/bin/mysqld.sh
[[email protected] ~]# vim /usr/lib/systemd/system/mysqld.service
[Unit]
Description=MySQL Server
After=network.target

[Service]
User=mysql  #指定程序运行的用户账户
Group=mysql #指定程序运行的组账户

Type=forking
PIDFile=/usr/local/mysql/data/localhost.pid #指定PID文件的位置,默认为“主机名.pid”
ExecStart=/usr/local/mysql/bin/mysqld.sh start
ExecStop=/usr/local/mysql/bin/mysqld.sh stop

[Install]
WantedBy=mutil-user.target

[[email protected] ~]# systemctl start mysqld
[[email protected] ~]# systemctl enable mysqld
Created symlink from /etc/systemd/system/mutil-user.target.wants/mysqld.service to /usr/lib/systemd/system/mysqld.service.

[[email protected] ~]# systemctl status mysqld
● mysqld.service - MySQL Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: active (running) since 六 2018-12-08 09:54:04 CST; 42s ago
 Main PID: 2520 (mysqld)
   CGroup: /system.slice/mysqld.service
           ├─2364 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/usr/local/mysql/data --pid...
           └─2520 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/my...

12月 08 09:53:57 localhost systemd[1]: Starting MySQL Server...
12月 08 09:54:04 localhost systemd[1]: mysqld.service: Supervising process 2520 which is not...ts.
12月 08 09:54:04 localhost systemd[1]: Started MySQL Server.
12月 08 09:54:16 localhost systemd[1]: mysqld.service: Supervising process 2520 which is not...ts.
Hint: Some lines were ellipsized, use -l to show in full.

[[email protected] ~]# netstat -lnpt | grep mysqld
tcp6       0      0 :::3306                 :::*                    LISTEN      2520/mysqld

MySQL默认通过TCP3306端口提供服务,可通过编辑/etc/my.cnf文件中"port=3306"行进行修改。

[[email protected] mysql]# mysqladmin -u root -p‘dskL0)8S3FGe‘ password 123456
[[email protected] mysql]# mysql -uroot -p123456
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.11 Source distribution

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.

mysql> exit
Bye
[[email protected] mysql]# 

原文地址:http://blog.51cto.com/crushlinux/2327929

时间: 2024-10-05 23:03:50

MySQL-8.0 源码包方式安装的相关文章

mysql的源码包方式安装(mysql5.5)

-------初写博客,希望在工作和日常中学习到的一些知识和经验与大家交流分享! 在Mysql5.5之后,使用源码包方式安装mysql就需要通过cmake方式进行编译了.以下内容介绍通过cmake方式安装mysql的步骤: 一:安装前准备. 1:检查系统中是否存在mysql用户与组. #grep "mysql" /etc/passwd 2:若存在,删除mysql用户与组. #userdel  -r mysql #groupdel  -r  mysql 3:创建mysql用户与组. #g

nginx-1.8.0源码包编译安装

nginx源码包编译安装 1.nginx简介 Nginx ("engine x") 是一个高性能的HTTP和 反向代理 服务器,也是一个 IMAP/POP3/SMTP 服务器. Nginx是一款轻量级的Web 服务器/反向代理服务器及电子邮件(IMAP/POP3)代理服务器,并在一个BSD-like 协议下发行. 2.安装nginx时必须先安装相应的编译工具 [[email protected] ~]# yum -y install gcc gcc-c++ autoconf autom

(一)使用源码包方式安装redis-2.8.13

下载redis http://download.redis.io/releases/redis-2.8.13.tar.gz 使用root用户安装redis [[email protected] ~]# id uid=0(root) gid=0(root) groups=0(root) [[email protected] ~]# ls -l redis-2.8.13.tar.gz -rw-r--r-- 1 oracle oinstall 1227538 Oct 23 14:53redis-2.8

CentOS7下源码包方式安装rabbitmq

1.先安装erlang http://www.cnblogs.com/justphp/p/6093880.html 2.下载rabbitmq rpm包: wget http://www.rabbitmq.com/releases/rabbitmq-server/v3.5.0/rabbitmq-server-3.5.0-1.noarch.rpm 3.安装rabbitmq rpm --import http://www.rabbitmq.com/rabbitmq-signing-key-public

源码包编译安装mariaDB

前言 MySQL是一个关系型数据库管理系统,是最流行的关系型数据库管理系统,由于其体积小.速度快.总体拥有成本低,并且之前是完全开源,所以大受欢迎.但由于后面MySQL卖给了SUN,随后SUN被Oracle收购,虽然也有开源免费版本,但是很多功能都需要另外购买商业版本,导致现在MySQL使用份额逐渐减少.所以MariaDB就是因为这种原因诞生出来,成为数据库管理系统是MySQL的一个分支. 先前已经使用二进制安装了mariaDB(详细请查看http://www.178linux.com/8787

liunx命令6 vim编辑、压缩命令、rpm、yum及源码包编译安装

[[email protected] ~]# yum install -y vim-enhanced vim打开文件编辑(有颜色) [[email protected] ~]# vim  !$                   //上一条命令的最后一条参数 [[email protected] ~]# vim +10 !$                //打开文件进入第十行 :set number                                 //显示行号 vim 一般模式

源码包编译安装之--实战

最近安装公司安排很多程序让源码安装的活,今天和大家分享一下. 本文就以nginx为例进行源码安装的讲解: 解压: 1.# tar xf nginx-1.4.7.tar.gz{xz|bz2|gz} 2.# cd nginx-1.4.7 ./configure 还需通过许多选项指定编译特性 查看: ./configure--help --prefix=PATH        setinstallation prefix     nginx安装路径 --prefix=PATH        set i

CentOS 7.0源码包搭建LNMP 实际环境搭建

Centos7+Nginx1.11.7+MySQL5.7.16+PHP7.1.0+openssl-1.1.0c 一.linux 系统限制配置 1.关闭系统防火墙 systemctl stop firewalld.service 关闭防火墙 systemctl disable firewalld.service  禁用防火墙 2.关闭SElinux sed -i 's/SELINUX=.*/SELINUX=disabled/g' /etc/selinux/config  setenforce 0 

linux平台下rpm方式和源码包方式安装mysql5.7

博主QQ:819594300 博客地址:http://zpf666.blog.51cto.com/ 有什么疑问的朋友可以联系博主,博主会帮你们解答,谢谢支持! 一.下载mysql的rpm包 Mysql5.7.19的下载地址是: http://dev.mysql.com/downloads/mysql/ 你会发现mysql支持的所有的系统的版本,如下所示: 这里我们选择Red Hat Enterprise Linux / Oracle Linux系统6版本的64位的mysql的rpm包 二.安装和