centos 7 环境 mysql 5.7源码安装

1.1mysql 5.7(内存至少1G以上,否则编译容易报错)

 

1.1.1.1下载并配置boost_1_59_0.tar.gz

 

wget –c http://nchc.dl.sourceforge.net/project/boost/boost/1.59.0/boost_1_59_0.tar.gz

 

mv boost_1_59_0   /usr/local/boost

1.1.1.2下载mysql

wget http://mirrors.163.com/mysql/Downloads/MySQL-5.7/mysql-5.7.25.tar.gz

 

解压缩

tar –xvf mysql-5.7.25.tar.gz

 

1.1.1.3源码安装mysql 5.7

安装依赖包

yum install gcc c ncurses-devel libaio bison gcc-c++  git cmake ncurses-devel  ncurses -y

 

 

开始预编译安装

 

cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql7 
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock 
-DMYSQL_DATADIR=/data/mysql7 
-DSYSCONFDIR=/usr/local/mysql7 
-DMYSQL_USER=mysql 
-DMYSQL_TCP_PORT=3307 
-DWITH_XTRADB_STORAGE_ENGINE=1 
-DWITH_INNOBASE_STORAGE_ENGINE=1 
-DWITH_PARTITION_STORAGE_ENGINE=1 
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 
-DWITH_MYISAM_STORAGE_ENGINE=1 
-DWITH_READLINE=1 
-DENABLED_LOCAL_INFILE=1 
-DWITH_EXTRA_CHARSETS=1 
-DDEFAULT_CHARSET=utf8 
-DDEFAULT_COLLATION=utf8_general_ci 
-DEXTRA_CHARSETS=all 
-DWITH_BIG_TABLES=1 
-DWITH_DEBUG=0 
-DENABLE_DTRACE=0 
-DDOWNLOAD_BOOST=1 
-DWITH_BOOST=/usr/local/boost 
-DWITH_EMBEDDED_SERVER=OFF

 

 

collect2: error: ld returned 1 exit status
make[2]: *** [libmysqld/examples/mysql_client_test_embedded] Error 1
make[1]: *** [libmysqld/examples/CMakeFiles/mysql_client_test_embedded.dir/all] Error 2
make: *** [all] Error 2

如果编译如上报错可以添加如该参数试试:-DWITH_EMBEDDED_SERVER=OFF

编译

make –j4  多线程编译速度比较快

安装

make install

 

 

1.1.14 添加配置文件创建数据文件目录和启动文件并初始化

 

 

 

 

创建数据文件目录

mkdir -p /data/mysql7

创建mysql用户

useradd -s /sbin/nologin mysql

chown -R mysql. /data/mysql7

添加启动脚本

cp support-files/mysql.server /etc/init.d/mysqld7

chmod +x /etc/init.d/mysqld

 

添加mysql配置文件

vim /usr/local/mysql7/my.cnf

[mysqld]

basedir=/usr/local/mysql7/

datadir=/data/mysql7/

port=3307

pid-file=/data/mysql7/mysql7.pid

socket=/tmp/mysql.sock

[mysqld_safe]

log-error=/data/mysql7/mysql7.log

 

#执行初始化

/usr/local/mysql7/bin/mysqld --initialize --user=mysql --datadir=/data/mysql7 --basedir=/usr/local/mysql7/

 

 

 

[root@localhost mysql-5.7.25]# /usr/local/mysql7/bin/mysqld --initialize --user=mysql --datadir=/data/mysql7 --basedir=/usr/local/mysql7/

2019-12-24T13:11:27.394286Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).

2019-12-24T13:11:27.795706Z 0 [Warning] InnoDB: New log files created, LSN=45790

2019-12-24T13:11:27.858677Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.

2019-12-24T13:11:27.920763Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: e4fb685f-264e-11ea-9a46-000c2936562f.

2019-12-24T13:11:27.921883Z 0 [Warning] Gtid table is not ready to be used. Table mysql.gtid_executed cannot be opened.

2019-12-24T13:11:27.923154Z 1 [Note] A temporary password is generated for root@localhost: iB1)dL+K*Rgp

 

 

1.1.1.5启动mysql

 

 

/etc/init.d/mysqld start

 

 

1.1.1.6添加物密码登录配置,登录mysql

跳过权限:

vim /usr/local/mysql7/my.cnf

[mysqld]字段下添加:

skip-grant-tables

重启mysql

/etc/init.d/mysqld restart

 

1.1.1.7免密登录mysql设置:并更新mysql密码:

 

update mysql.user set authentication_string=password(‘123456‘) where user="root";

 

 

1.1.1.8输入密码也能够正常登录,去掉免密登录配置,重启后正常登录

去掉skip-grant-tables

[root@localhost bin]# more ../my.cnf

[mysqld]

basedir=/usr/local/mysql7/

datadir=/data/mysql7/

port=3306

pid-file=/data/mysql7/mysql7.pid

socket=/tmp/mysql.sock

[mysqld_safe]

log-error=/data/mysql7/mysql7.log

[root@localhost bin]#

 

 

 

重启mysql:

[root@localhost mysql7]# /etc/init.d/mysqld restart

Shutting down MySQL.. SUCCESS!

Starting MySQL. SUCCESS!

重启登录输入用户密码:root/123456

 [root@localhost bin]# ./mysql -uroot -p

Enter password:

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

Your MySQL connection id is 3

Server version: 5.7.25 Source distribution

 

Copyright (c) 2000, 2019, 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>

 

centos 7 环境 mysql 5.7源码安装

上一篇:Oracle OCP 19c 认证1Z0-083考试题库(第4题)


下一篇:Postgresql索引结构-Hash