名称 | 版本 |
---|---|
操作系统 | Red Hat Enterprise Linux Server release 7.9 (Maipo) |
CPU | 12th Gen Intel® Core™ i7-12700H |
内存 | 5G |
cmake | 3.23.1 |
openssl | 1.1.1 |
Mysql | 8.0.29 |
gcc | 7.3.1 |
注意:
(1)Mysql-8.0.29-源码编译,cmake版本大于等于3.5.1。
(2)Mysql-8.0.29-源码编译,gcc版本大于等于5.8。
(3)cmake高版本源码编译需要高版本openssl。
Mysql、openssl、cmake等源码的百度云盘下载链接
链接:https://pan.baidu.com/s/1OpYKk-UMDwvCfJQmLPIpvg
提取码:odzy
vim /etc/yum.repos.d/CentOS-Base.repo
注释原有base,添加如下内容:
[base]
name=CentOS-os
baseurl=http://mirrors.aliyun.com/centos/7/os/x86_64/
gpgcheck=0
[centos-sclo-sclo]
name=CentOS-7 - SCLo sclo
baseurl=http://mirrors.aliyun.com/centos/7/sclo/x86_64/sclo/
gpgcheck=0
[centos-sclo-rh]
name=CentOS-7 - SCLo rh
baseurl=http://mirrors.aliyun.com/centos/7/sclo/x86_64/rh/
gpgcheck=0
#[base]
#name=CentOS-$releasever - Base
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
#gpgcheck=1
#gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
yum install openssl-devel
unzip openssl-OpenSSL_1_1_1.zip
cd openssl-OpenSSL_1_1_1
./config shared zlib enable-ssl3 enable-ssl3-method --prefix=/usr/local/openssl
make -j4
make install
/usr/local/openssl/lib
export LD_LIBRARY_PATH=/opt/mysql/openssl-OpenSSL_1_1_1:$LD_LIBRARY_PATH
export OPENSSL_ROOT_DIR=/opt/mysql/openssl-OpenSSL_1_1_1
export OPENSSL_CRYPTO_LIBRARY=/opt/mysql/openssl-OpenSSL_1_1_1/crypto
export OPENSSL_INCLUDE_DIR=/opt/mysql/openssl-OpenSSL_1_1_1/include
export CMAKE_C_COMPILER=/usr/bin/gcc
export CMAKE_CXX_COMPILER=/usr/bin/g++
/sbin/ldconfig -v
. /etc/profile
cp /usr/local/openssl/bin/openssl /usr/local/bin
[root@xdw0 datax]# openssl version
OpenSSL 1.1.1 11 Sep 2018
请参考之前的文章
《SingleStore数据库(mysql分布式)-ODBC接口源码编译及ODBC接口Demo》中的三、安装Cmake
yum install devtoolset-7-gcc* -y
yum install devtoolset-11-gcc devtoolset-11-gcc-c++ devtoolset-11-binutils
scl enable devtoolset-7 bash
[root@xdw0 ~]# gcc --version
gcc (GCC) 7.3.1 20180303 (Red Hat 7.3.1-5)
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
scl enable devtoolset-7 bash
. /etc/profile
yum install ncurses ncurses-devel bison bison-devel zlib* -y
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/mysql/data \
-DMYSQL_UNIX_ADDR=/mysql/data/mysql.sock \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DSYSCONFDIR=/etc \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_EXTRA_CHARSETS=all \
-DDEFAULT_CHARSET=utf8mb4 \
-DDEFAULT_COLLATION=utf8mb4_0900_ai_ci \
-DWITH_BOOST=/opt/mysql/mysql-8.0.29/include/boost_1_77_0 \
-DDOWNLOAD_BOOST=1 \
-DFORCE_INSOURCE_BUILD=1 \
-DDOWNLOAD_BOOST_TIMEOUT=10000
参数说明:
DCMAKE_INSTALL_PREFIX ##安装路径
DMYSQL_DATADIR ##指定数据目录
DMYSQL_UNIX_ADDR ##指定套接字文件
DWITH_INNOBASE_STORAGE_ENGINE ##使用innodb引擎
DSYSCONFDIR ##指定配置目录
DENABLED_LOCAL_INFILE ##支持本地大文件导入数据
DWITH_EXTRA_CHARSETS ##支持外部扩展字符集
DDEFAULT_CHARSET ##默认使用utf8mb4字符集
DWITH_BOOST ##c++boost库
make
make install
groupadd mysql -g 2001
useradd mysql -g 2001 -u 2001
echo "mysql"|passwd --stdin mysql
mkdir -p /mysql/data
mkdir -p /usr/local/mysql
chown -R mysql:mysql /usr/local/mysql
chown -R mysql:mysql /mysql/data
chmod 750 /mysql/data
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
basedir=/usr/local/mysql
datadir=/mysql/data
chmod +x /etc/init.d/mysqld
systemctl enable mysqld
[root@xdw0 data]# cat /etc/my.cnf
[client]
default-character-set=utf8mb4
[mysql]
default-character-set=utf8mb4
[mysqld]
basedir=/usr/local/mysql
datadir=/mysql/data
socket=/mysql/data/mysql.sock
symbolic-links=0
bind-address = 0.0.0.0
user = mysql
character_set_server = utf8mb4
collation-server = utf8mb4_unicode_ci
max_connections = 100
max_connect_errors = 100
# 交互式客户端连接后,没有任何操作的情况下,继续保持连接状态的秒数
interactive_timeout = 1800
#skip-grant-tables=1
[mysqld_safe]
log-error=/tmp/mysqld.log
pid-file=/tmp/mysql.pid
expire_logs_days=30
#
# include all files from the config directory
#
!includedir /etc/my.cnf.d
cd /usr/local/mysql/bin
[mysql@xdw0 bin]$ ./mysqld --initialize-insecure --user=mysql
2022-05-05T01:19:03.977020Z 0 [Warning] [MY-011070] [Server] 'Disabling symbolic links using --skip-symbolic-links (or equivalent) is the default. Consider not using this option as
it' is deprecated and will be removed in a future release.2022-05-05T01:19:03.977134Z 0 [System] [MY-013169] [Server] /usr/local/mysql/bin/mysqld (mysqld 8.0.29) initializing of server in progress as process 93773
2022-05-05T01:19:03.984829Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2022-05-05T01:19:04.181853Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2022-05-05T01:19:04.740154Z 6 [Warning] [MY-010453] [Server] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
--initialize-insecure 使用空密码。
[root@xdw0 data]# systemctl start mysqld
[root@xdw0 data]# su - mysql
[mysql@xdw0 bin]$ ./mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 8.0.29 Source distribution
Copyright (c) 2000, 2022, Oracle and/or its affiliates.
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> select version();
+-----------+
| version() |
+-----------+
| 8.0.29 |
+-----------+
1 row in set (0.00 sec)
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'qwer1234';
Query OK, 0 rows affected (0.01 sec)
mysql> CREATE USER 'root'@'%' IDENTIFIED BY 'qwer1234';
Query OK, 0 rows affected (0.01 sec)
mysql> grant all privileges on *.* to 'root'@'%';
Query OK, 0 rows affected (0.00 sec)
mysql> SET PASSWORD FOR 'root'@'%' = PASSWORD('qwer1234');
Query OK, 0 rows affected (0.00 sec)
或
mysql> ALTER USER root@'%' IDENTIFIED BY 'qwer1234' PASSWORD EXPIRE NEVER;
Query OK, 0 rows affected (0.01 sec)
mysql> set global local_infile=ON;
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> select host,user from user;
+-----------+------------------+
| host | user |
+-----------+------------------+
| % | root |
| localhost | mysql.infoschema |
| localhost | mysql.session |
| localhost | mysql.sys |
| localhost | root |
+-----------+------------------+
5 rows in set (0.00 sec)