资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

mysql如何源码安装5.7-17-19版本

这篇文章将为大家详细讲解有关MySQL如何源码安装5.7-17-19版本,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。

网站建设哪家好,找创新互联!专注于网页设计、网站建设、微信开发、小程序定制开发、集团企业网站建设等服务项目。为回馈新老客户创新互联还提供了通海免费建站欢迎大家使用!

由于项目需要,现在要使用5.7.19版本的mysql

1:首先下载mysql 二进制安装文件

mysql-5.6.19.tar.gz

存放目录/mysql/mysql-5.6.19.tar.gz

tar -xf mysql-5.6.19.tar.gz

cd mysql-5.6.19

进行cmake,但是提示Cmake版本过低,至少需要2.8的版本

2:下载cmake 

cmake-2.8.10.2.tar.gz

tar -xf cmake-2.8.10.2.tar.gz

./configure

make && make install

3:进行cmake

    先创建mysql 安装目录以及数据文件存放目录

        mkdir -p /mysql/mysql

        mkdir -p /mysql/mysql/data

    同时需要创建mysql 账号

        useradd mysql

        passwd mysql

    再进行目录授权:

        chown -R mysql:mysql /mysql

这个是5.7.17版本的编译安装

   cd mysql-5.6.17

 cmake \

        -DCMAKE_INSTALL_PREFIX=/mysql/ \               //mysql软件安装的根目录

        -DMYSQL_DATADIR=/mysql/data \                   //mysql 数据文件存放目录

        -DSYSCONFDIR=/etc \                                    //mysql 配置文件(my.cnf)目录

        -DWITH_MYISAM_STORAGE_ENGINE=1 \         //存储引擎选项

        -DWITH_INNOBASE_STORAGE_ENGINE=1 \    //以启用InnoDB、引擎支持:

        -DWITH_MEMORY_STORAGE_ENGINE=1 \

        -DWITH_READLINE=1 \                                 

        -DMYSQL_UNIX_ADDR=/var/lib/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          //字符集校对

    进行编译,编译时报错如下:

            heck size of wctype_t - done

            -- Check size of wint_t

            -- Check size of wint_t - done

            -- Could NOT find Curses (missing:  CURSES_LIBRARY CURSES_INCLUDE_PATH) 

                CMake Error at cmake/readline.cmake:85 (MESSAGE):

                  Curses library not found.  Please install appropriate package,

              remove CMakeCache.txt and rerun cmake.On Debian/Ubuntu, package name is libncurses5-dev, on Redhat and derivates it is ncurses-devel.

            Call Stack (most recent call first):

              cmake/readline.cmake:128 (FIND_CURSES)

              cmake/readline.cmake:202 (MYSQL_USE_BUNDLED_EDITLINE)

              CMakeLists.txt:411 (MYSQL_CHECK_EDITLINE)

    这个报错是提示缺少ncurses-devel依赖包

    进行下载:ncurses-devel-5.7-3.20090208.el6.x86_64.rpm

        rpm -ivh ncurses-devel-5.7-3.20090208.el6.x86_64.rpm 

        warning: ncurses-devel-5.7-3.20090208.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY

        Preparing...                ########################################### [100%]

       1:ncurses-devel          ########################################### [100%]

    同时rm -rf CMakeCache.txt 然后进行重新cmake

        完成之后,进行make && make install 进行mysql 安装

        - Installing: /mysql/man/man1/msql2mysql.1

        -- Installing: /mysql/man/man8/mysqld.8

        -- Installing: /mysql/support-files/solaris/postinstall-solaris

        算安装完成了,接下来就需要进行配置

这是5.7.17的步骤

4: 进入到mysql的安装目录,/mysql下:进行mysql 数据库初始化

        scripts/mysql_install_db --basedir=mysql --datadir=/mysql/data --user=mysql  //初始化mysql数据库

      但是报错

        [root@db_test scripts]# ./mysql_install_db  --basedir=mysql --datadir=/mysql/data --user=mysql

            FATAL ERROR: Could not find ./bin/my_print_defaults

               cd  /u01/soft/mysql-5.6.17/support-files

            cp  my-default.cnf /usr/local/mysql/my.cnf //copy配置文件

            [root@db_test support-files]# chown -R mysql:mysql /mysql

        vi /my.cnf 添加以下内容

    [mysqld]

    basedir = /mysql          

    datadir = /mysql/data  

    log-error = /mysql/mysql_error.log          

    pid-file = /mysql/mysql.pid          

    user = mysql

    tmpdir = /tmp 

    初始化mysql数据库

[root@db_test scripts]# ./mysql_install_db  --basedir=/mysql --datadir=/mysql/data --user=mysql

Installing MySQL system tables...2017-05-11 15:01:56 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).

2017-05-11 15:01:56 8161 [Note] InnoDB: Using atomics to ref count buffer pool pages

2017-05-11 15:01:56 8161 [Note] InnoDB: The InnoDB memory heap is disabled

2017-05-11 15:01:56 8161 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins

2017-05-11 15:01:56 8161 [Note] InnoDB: Compressed tables use zlib 1.2.3

2017-05-11 15:01:56 8161 [Note] InnoDB: Using CPU crc32 instructions

2017-05-11 15:01:56 8161 [Note] InnoDB: Initializing buffer pool, size = 128.0M

2017-05-11 15:01:56 8161 [Note] InnoDB: Completed initialization of buffer pool

2017-05-11 15:01:56 8161 [Note] InnoDB: Highest supported file format is Barracuda.

2017-05-11 15:01:56 8161 [Note] InnoDB: Log scan progressed past the checkpoint lsn 1600617

2017-05-11 15:01:56 8161 [Note] InnoDB: Database was not shutdown normally!

2017-05-11 15:01:56 8161 [Note] InnoDB: Starting crash recovery.

2017-05-11 15:01:56 8161 [Note] InnoDB: Reading tablespace information from the .ibd files...

2017-05-11 15:01:56 8161 [Note] InnoDB: Restoring possible half-written data pages 

2017-05-11 15:01:56 8161 [Note] InnoDB: from the doublewrite buffer...

    或使用下列命令把mysql添加为系统服务

    cd/mysql/support-files/   

    cp ./mysql.server /etc/init.d/mysqld  

    /etc/init.d/mysqld start

    在配置环境变量

export PATH=$PATH:/mysql/bin

    [mysql@db_test ~]$ mysql

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 1

Server version: 5.6.17 Source distribution

Copyright (c) 2000, 2014, 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> show databases;

+--------------------+

| Database           |

+--------------------+

| information_schema |

| test               |

+--------------------+

2 rows in set (0.00 sec)

5:5.7.19版本的安装步骤

5.7.19版本安装是时候提示

CMake Error at cmake/boost.cmake:81 (MESSAGE):

  You can download it with -DDOWNLOAD_BOOST=1 -DWITH_BOOST=

所以下载boost软件

[root@localhost ~]# wget http://sourceforge.net/projects/boost/files/boost/1.59.0/boost_1_59_0.tar.gz

tar -xf boost_1_59_0.tar.gz

cp -r boost_1_59_0 /usr/local/boost

进行安装

cmake \

-DCMAKE_INSTALL_PREFIX=/mysql/mysql \

-DMYSQL_DATADIR=/mysql/mysql/data \

-DDEFAULT_CHARSET=utf8 \

-DDEFAULT_COLLATION=utf8_general_ci \

-DMYSQL_TCP_PORT=3306 \

-DMYSQL_USER=mysql \

-DWITH_MYISAM_STORAGE_ENGINE=1 \

-DWITH_INNOBASE_STORAGE_ENGINE=1 \

-DWITH_ARCHIVE_STORAGE_ENGINE=1 \

-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \

-DWITH_MEMORY_STORAGE_ENGINE=1 \

-DENABLE_DOWNLOADS=1 \

-DDOWNLOAD_BOOST=1 \

-DWITH_BOOST=/usr/boost  

完成之后,进行make && make install 

时间很长,可以出去抽根烟。

配置环境变量

export PATH=/mysql/mysql/bin:/mysql/mysql/lib:$PATH

时间很长

cd mysql/bin

./mysqld --initialize-insecure --user=mysql --basedir=/mysql/mysql --datadir=/mysql/data

[root@localhost mysql]# cp support-files/mysql.server /etc/init.d/mysqld

[root@localhost mysql]# chmod a+x /etc/init.d/mysqld

再编辑/etc/my.cnf

[mysqld]

datadir=/mysql/data

socket=/mysql/mysql.sock

user=mysql

# Disabling symbolic-links is recommended to prevent assorted security risks

symbolic-links=0

[mysqld_safe]

log-error=/mysql/mysql/logs/mysqld.log

pid-file=/mysql/mysql/logs/mysqld.pid

[client]

default-character-set=utf8

socket=/mysql/mysql.sock

[mysql]

default-character-set=utf8

socket=/mysql/mysql.sock

启动mysql

[root@localhost mysql]# service mysqld start

Starting MySQL.2018-08-30T01:45:21.383785Z mysqld_safe error: log-error set to '/mysql/mysql/logs/mysqld.log', however file don't exists. Create writable for user 'mysql'.

The server quit without updating PID file (/mysql/data/loca[失败]localdomain.pid)

报错,需要创建文件。

[root@localhost logs]# touch mysqld.log

[root@localhost logs]# touch mysqld.pid

[root@localhost logs]# chown -R mysql:mysql /mysql

 [root@localhost mysql]# service mysqld start

Starting MySQL.                                            [确定]

[root@localhost mysql]# 

[mysql@localhost ~]$ mysql

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 3

Server version: 5.7.19 Source distribution

Copyright (c) 2000, 2017, 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> show databases;

+--------------------+

| Database           |

+--------------------+

| information_schema |

| mysql              |

| performance_schema |

| sys                |

+--------------------+

4 rows in set (0.00 sec)

mysql> 

再修改root的密码

Database changed

mysql> select host,user,authentication_string from user;

+-----------+---------------+-------------------------------------------+

| host      | user          | authentication_string                     |

+-----------+---------------+-------------------------------------------+

| localhost | root          |                                           |

| localhost | mysql.session | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE |

| localhost | mysql.sys     | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE |

+-----------+---------------+-------------------------------------------+

3 rows in set (0.00 sec)

mysql> UPDATE user SET authentication_string=PASSWORD('shenzhen#123')WHERE user='root';

Query OK, 1 row affected, 1 warning (0.01 sec)

Rows matched: 1  Changed: 1  Warnings: 1

mysql> flush privileges;

Query OK, 0 rows affected (0.00 sec)

mysql> select host,user,authentication_string from user;

+-----------+---------------+-------------------------------------------+

| host      | user          | authentication_string                     |

+-----------+---------------+-------------------------------------------+

| localhost | root          | *4E25F9206A350692D2F5AC0512B41C69759FF312 |

| localhost | mysql.session | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE |

| localhost | mysql.sys     | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE |

+-----------+---------------+-------------------------------------------+

3 rows in set (0.00 sec)

mysql> 

mysql> 

关于“mysql如何源码安装5.7-17-19版本”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,使各位可以学到更多知识,如果觉得文章不错,请把它分享出去让更多的人看到。


网站名称:mysql如何源码安装5.7-17-19版本
分享网址:http://cdkjz.cn/article/pppgjc.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

大客户专线   成都:13518219792   座机:028-86922220