ARM平台编译安装MySQL5.7.29,gcc编译器更新7.3

1.更新gcc编译器

yum install -y  gcc gcc-c++ cmake ncurses ncurses-devel bison #先检查一下依赖
cd /usr/src
wget https://mirrors.ustc.edu.cn/gnu/gcc/gcc-7.3.0/gcc-7.3.0.tar.gz
tar -zvxf gcc-7.3.0.tar.gz 
cd gcc-7.3.0
./contrib/download_prerequisites
./configure --enable-checking=release --enable-languages=c,c++ --disable-multilib
make -j8		#八线程编译模式 CPU不行就低一些 这个实在是太慢了
rpm -q gcc		#寻找已安装的gcc
rpm -q gcc-c++  #寻找已安装的c++
rpm -e [包名]	#上一部显示啥就卸载啥
make install	#执行安装
which gcc		#查找gcc位置
ln -s /usr/local/bin/gcc /usr/bin/gcc #建立软连接
ln -s /usr/local/bin/gcc /usr/bin/cc
ln -s /usr/local/bin/g++ /usr/bin/c++
mv /usr/lib64/libstdc++.so.6 /usr/lib64/libstdc++.so.6.bak #更新库
ln -s /usr/local/lib64/libstdc++.so.6 /usr/lib/libstdc++.so.6
#这个干嘛用的忘了,,,不执行试试?
ln -s /usr/local/lib64/libatomic.so.1 /usr/lib64/libatomic.so.1

2.处理ARM平台MySQL的源码和bug

下载页如图

https://downloads.mysql.com/archives/community/

ARM平台编译安装MySQL5.7.29,gcc编译器更新7.3_第1张图片

cd /usr/src
wget https://cdn.mysql.com/archives/mysql-5.7/mysql-boost-5.7.29.tar.gz
tar -zvxf mysql-boost-5.7.29.tar.gz
cd mysql-boost-5.7.29
vi storage/innobase/include/os0atomic.h

在图中位置添加代码

#else
#define HAVE_ATOMIC_BUILTINS

ARM平台编译安装MySQL5.7.29,gcc编译器更新7.3_第2张图片

搜索
# ifdef HAVE_IB_ATOMIC_PTHREAD_T_GCC
修改
# ifdef HAVE_IB_ATOMIC_PTHREAD_T_GCC
#if defined(HAVE_GCC_SYNC_BUILTINS)# ifdef HAVE_ATOMIC_BUILTINS
#if defined(HAVE_ATOMIC_BUILTINS)

ARM平台编译安装MySQL5.7.29,gcc编译器更新7.3_第3张图片

vi storage/innobase/include/os0atomic.ic
搜索
#elif defined(IB_STRONG_MEMORY_MODEL)
修改为
#elif defined(HAVE_ATOMIC_BUILTINS)

ARM平台编译安装MySQL5.7.29,gcc编译器更新7.3_第4张图片
查找你系统中的这个文件 没有就百度去吧 (据说这是个bug)

find / -name "prctl.h"
vi sql/mysqld.cc
#将你的文件丢进去 如下代码包含"#" 不用去掉
#include

3.编译安装MySQL5.7.29

mkdir /usr/local/mysql
mkdir /usr/local/mysql/data
cd /usr/src/mysql-5.7.29
cmake -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_BOOST=boost
make -j8 #继续加速。。。慢的要死 理论完成上述操作不会出现报错
make install
vi /etc/my.cnf #配置文件

这是我的 按需修改

[client]
port        = 3389
socket      = /tmp/mysql.sock

[mysqld]
port        = 3389
socket      = /tmp/mysql.sock
user = root #以root允许确保不会出现权限问题

basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
pid-file = /usr/local/mysql/log/mysql.pid
log_error = /usr/local/mysql/log/error.log
slow_query_log = 1
long_query_time = 1
slow_query_log_file = /usr/local/mysql/log/slow.log

skip-external-locking
key_buffer_size = 32M
max_allowed_packet = 1024M
table_open_cache = 128
sort_buffer_size = 768K
net_buffer_length = 8K
read_buffer_size = 768K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M
thread_cache_size = 16
query_cache_size = 16M
tmp_table_size = 32M
performance_schema_max_table_instances = 1000

explicit_defaults_for_timestamp = true
#skip-networking
max_connections = 9999
max_connect_errors = 100
open_files_limit = 65535

log_bin=mysql-bin
binlog_format=mixed
server_id   = 232
expire_logs_days = 10
early-plugin-load = ""

default_storage_engine = InnoDB
innodb_file_per_table = 1
innodb_buffer_pool_size = 128M
innodb_log_file_size = 32M
innodb_log_buffer_size = 8M
innodb_flush_log_at_trx_commit = 1
innodb_lock_wait_timeout = 50

[mysqldump]
quick
max_allowed_packet = 16M

[mysql]
no-auto-rehash

[myisamchk]
key_buffer_size = 32M
sort_buffer_size = 768K
read_buffer = 2M
write_buffer = 2M

4.初始化并配置

ln -s /usr/local/mysql/support-files/mysql.server /usr/bin/mysqld
ln -s /usr/local/mysql/bin/mysql /usr/bin/mysql
mysqld --initialize-insecure --user=root --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data #初始化数据库 路径需与配置文件一致
mysqld start #启动数据库
mysql -hlocalhost -uroot -p #以root用户登录数据库 应该不需要密码
use mysql
SELECT User, authentication_string, Host FROM user; #查看用户
update user set authentication_string = password('root'), password_expired = 'N', password_last_changed = now() where user = 'root'; #修改root密码为root
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION; #允许root远程登录
FLUSH PRIVILEGES; #更新权限
SELECT User, authentication_string, Host FROM user; #查看用户
exit #退出数据库

使用Navicat远程连接 (Navicat牛批!)
ARM平台编译安装MySQL5.7.29,gcc编译器更新7.3_第5张图片

部分参考:

https://www.cnblogs.com/cyanrose/p/11471455.html
https://blog.csdn.net/rbpicsdn/article/details/79565383
https://blog.csdn.net/zhang_referee/article/details/88212695
https://www.veryarm.com/35645.html
https://bbs.huaweicloud.com/forum/thread-47298-1-1.htm
https://www.cnblogs.com/beyang/p/9979384.html
https://blog.csdn.net/zhazhagu/article/details/81064406

你可能感兴趣的:(ARM平台编译安装MySQL5.7.29,gcc编译器更新7.3)