5.7.11编译安装详解(2)

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:107 (FIND_CURSES)
cmake/readline.cmake:181 (MYSQL_USE_BUNDLED_EDITLINE)
CMakeLists.txt:471 (MYSQL_CHECK_EDITLINE)

这个错误是说明缺少Curses库yum install ncurses-devel,需要注意的是每次编译错误都要移除CMakeCache.txt,最后出现 Build files have been written 即成功

CMake Warning:
Manually-specified variables were not used by the project:

DOWNLOAD_BOOST
WITH-LIBWRAP
WITH_MEMORY_STORAGE_ENGINE
WITH_READLINE


-- Build files have been written to: /root/mysql-5.7.11

使用make大约两个小时的样子编译完成,到百分之五十几的时候停留的时间比较长。

5.7.11编译安装详解

make install

出现一堆安装信息即完成安装

-- Installing: /usr/local/mysql/mysql-test/./cmake_install.cmake
-- Installing: /usr/local/mysql/mysql-test/./CTestTestfile.cmake
-- Up-to-date: /usr/local/mysql/mysql-test/mtr
-- Up-to-date: /usr/local/mysql/mysql-test/mysql-test-run
-- Installing: /usr/local/mysql/mysql-test/lib/My/SafeProcess/my_safe_process
-- Up-to-date: /usr/local/mysql/mysql-test/lib/My/SafeProcess/my_safe_process
-- Installing: /usr/local/mysql/mysql-test/lib/My/SafeProcess/Base.pm
-- Installing: /usr/local/mysql/support-files/my-default.cnf
-- Installing: /usr/local/mysql/support-files/mysqld_multi.server
-- Installing: /usr/local/mysql/support-files/mysql-log-rotate
-- Installing: /usr/local/mysql/support-files/magic
-- Installing: /usr/local/mysql/share/aclocal/mysql.m4
-- Installing: /usr/local/mysql/support-files/mysql.server
[root@localhost mysql-5.7.11]#

0x04 安装后目录创建

socket=/var/run/mysql/mysql.sock
basedir = /usr/local/mysql
datadir = /mymnt/sqldata
socket=/var/run/mysql/mysql.sock
log-error = /var/log/mysql/error.log
pid-file = /var/log/mysql/mysql.pid

如配置文件关于目录相关的部分,我们需要创建/var/run/mysql ,  /mymnt/sqldata  ,  /var/log

创建mysql用户和组,将数据目录  /mymnt/sqldata 和安装目录/var/run/mysql的属主(组)更改成mysql

[root@localhost mysql]# groupadd -r mysql
[root@localhost mysql]# useradd -r -g mysql -s /sbin/nologin mysql

[root@localhost mysql]# mkdir /var/run/mysql
[root@localhost mysql]# mkdir /var/log/mysql
[root@localhost mysql]# chown mysql:mysql /var/run/mysql/
[root@localhost mysql]# chown mysql:mysql /var/log/mysql/
[root@localhost mysql]# chown mysql:mysql /mymnt/sqldata/
[root@localhost mysql]# chown -R mysql:mysql /usr/local/mysql

0x05 初始化

1、mysql-5.7版本的my.cnf文件在support-files/下并没有模板文件,自行添加配置文件

2、将安装目录下support-files/mysql.server 启动脚本复制到 /etc/init.d/mysqld,以便实现开机启动。也可以[root@localhost mysql]# ./support-files/mysql.server start 临时启动

未启动时执行mysql命令会报错如下:

[root@localhost mysql]# mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysql/mysql.sock' (2)

3、添加环境变量以便使用初始化命令 export PATH=/usr/local/mysql/bin:$PATH

4、初始化

mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/mymnt/sqldata

0x06 其他

1、mysqld_safe

  mysqld 和 mysqld_safe都可以启动mysql。直接运行mysqld程序来启动MySQL服务的方法很少见,mysqld_safe脚本会在启动MySQL服务器后继续监控其运行情况,并在其死机时重新启动它。

我们可以发现这是一个shell脚本,在Unix和NetWare中推荐使用mysqld_safe来启动mysqld服务器。mysqld_safe增加了一些安全特性,例如当出现错误时重启服务器并向错误日志文件写入运行时间信息。

[root@localhost mysql]# file bin/mysqld
bin/mysqld: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=0x772828c9d330090391cd89dbe699f041a378944d, not stripped
[root@localhost mysql]# file bin/mysqld_safe
bin/mysqld_safe: POSIX shell script, ASCII text executable

2、mysql_secure_installation

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/5d0588b399d53a905b43556f45da81e9.html