源码安装mysql 8图解

本文涉及的产品
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
云数据库 RDS MySQL,集群系列 2核4GB
推荐场景:
搭建个人博客
云数据库 RDS PostgreSQL,集群系列 2核4GB
简介:

1,官网下载

wget https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-8.0.12.tar.gz

wget https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-boost-8.0.12.tar.gz

2,添加mysql用户

useradd mysql -s /sbin/nologin

3,安装基础软件

yum -y install wget cmake gcc gcc-c++ ncurses ncurses-devel libaio-devel openssl openssl-devel

1234

4, 解压mysql和解压boost到/usr/local

tar xf mysql-8.0.12.tar.gz
tar zxf mysql-boost-8.0.12.tar.gz -C /usr/local/

5,编译mysql

cd /usr/local/src/mysql-8.0.12
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/data -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/usr/local/mysql-8.0.12/ -DSYSCONFDIR=/etc -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DWITH_FEDERATED_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_EMBEDDED_SERVER=1 -DENABLE_DTRACE=0 -DENABLED_LOCAL_INFILE=1 -DDEFAULT_CHARSET=utf8mb4

23456
6,安装mysql

make && make install --大约20分钟

33333333334444
7,配置好my.cnf

[client]

port = 3306
socket = /tmp/mysql.sock
default-character-set = utf8mb4

[mysql]
prompt="MySQL [\d]> "
no-auto-rehash

[mysqld]
port = 3306
socket = /tmp/mysql.sock
default_authentication_plugin = mysql_native_password
basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
pid-file = /usr/local/mysql/data/mysql.pid
user = mysql
server-id = 1

init-connect = 'SET NAMES utf8mb4'
character-set-server = utf8mb4
collation-server = utf8mb4_0900_ai_ci

skip-name-resolve
back_log = 300
max_connections = 1000
max_connect_errors = 6000
open_files_limit = 65535
table_open_cache = 128
max_allowed_packet = 500M
binlog_cache_size = 1M
max_heap_table_size = 8M
tmp_table_size = 16M
read_buffer_size = 2M
read_rnd_buffer_size = 8M
sort_buffer_size = 8M
join_buffer_size = 8M
key_buffer_size = 4M
thread_cache_size = 8
ft_min_word_len = 4
log_bin = mysql-bin
binlog_format = mixed
binlog_expire_logs_seconds = 604800
log_error = /usr/local/mysql/data/mysql-error.log
slow_query_log = 1
long_query_time = 1
slow_query_log_file = /usr/local/mysql/data/mysql-slow.log
performance_schema = 0
explicit_defaults_for_timestamp
skip-external-locking
default_storage_engine = InnoDB
innodb_file_per_table = 1
innodb_open_files = 500
innodb_buffer_pool_size = 64M
innodb_write_io_threads = 4
innodb_read_io_threads = 4
innodb_thread_concurrency = 0
innodb_purge_threads = 1
innodb_flush_log_at_trx_commit = 2
innodb_log_buffer_size = 2M
innodb_log_file_size = 32M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 90
innodb_lock_wait_timeout = 120

bulk_insert_buffer_size = 8M
myisam_sort_buffer_size = 8M
myisam_max_sort_file_size = 10G
myisam_repair_threads = 1

interactive_timeout = 28800
wait_timeout = 28800

[mysqldump]
quick
max_allowed_packet = 500M

[myisamchk]
key_buffer_size = 8M
sort_buffer_size = 8M
read_buffer = 4M
write_buffer = 4M
8,初始化mysql

cd /usr/local/mysql

mkdir data
chown -R mysql.mysql ./*
chown root.mysql /usr/local/mysql
bin/mysqld --initialize-insecure --user=mysql
77777777777777
9,配置MySQL8

echo "export PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile

. /etc/profile
cp support-files/mysql.server /etc/init.d/mysql8
chmod +x /etc/init.d/mysql8
sed -i "s@^datadir=.*@datadir=/usr/local/mysql/data@" /etc/init.d/mysql8
sed -i "s@^basedir=.*@basedir=/usr/local/mysql@" /etc/init.d/mysql8
[root@iZwz9hzc7pd8k6u859n9rzZ mysql]# /etc/init.d/mysql8 restart
MySQL server PID file could not be found! [FAILED]
Starting MySQL.

                                     [  OK  ]

99999999999999
10,配置MySQL8 的密码

[root@iZwz9hzc7pd8k6u859n9rzZ mysql]# mysql -u root -p
Enter password:

ERROR 2059 (HY000): Authentication plugin 'caching_sha2_password' cannot be loaded: /usr/lib64/mysql/plugin/caching_sha2_password.so: cannot open shared object file: No such file or directory
报这个错,意思是少了这个插件
需要mysql8自己的客户端才能连接,所以用全路径连接mysql8
[root@iZwz9hzc7pd8k6u859n9rzZ data]# /usr/local/mysql/bin/mysql -u root -p
666666666666666
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 803
Server version: 8.0.12 Source distribution

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

  1. Other names may be trademarks of their respective
    owners.

Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.

MySQL [(none)]> alter user root@'localhost' identified by '123456';
Query OK, 0 rows affected (0.01 sec)

MySQL [(none)]> alter user root@'127.0.0.1' identified by '123456';
ERROR 1396 (HY000): Operation ALTER USER failed for 'root'@'127.0.0.1'
MySQL [(none)]> flush privileges;
Query OK, 0 rows affected (0.01 sec)

MySQL [(none)]>
重新登陆mysql8
88888888888
mysql8源码安装完成。
我的阿里云优惠券地址:https://promotion.aliyun.com/ntms/yunparter/invite.html?userCode=3ow2kbko

相关实践学习
如何在云端创建MySQL数据库
开始实验后,系统会自动创建一台自建MySQL的 源数据库 ECS 实例和一台 目标数据库 RDS。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助     相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
目录
相关文章
|
关系型数据库 MySQL 数据库
mysql源码安装详解
mysql源码安装详解
319 0
mysql源码安装详解
|
2月前
|
关系型数据库 MySQL Linux
【一键解锁神秘力量!】CentOS 7 通过编译源码方式安装 MySQL 数据库 —— 从零到英雄的数据库安装实战秘籍!
【8月更文挑战第9天】随着业务增长,对数据库的需求日益提高。在 CentOS 7 中,通过编译源码安装 MySQL 可提供更高定制性和灵活性。本文详细介绍从准备环境、下载源码、配置编译参数到安装 MySQL 的全过程,并对比 RPM 包安装方法,帮助读者根据需求选择合适方案。实践时需注意备份数据、选择合适版本、确保安全性和调优性能等要点。
162 1
|
关系型数据库 MySQL C语言
源码安装MySQL8.0 1
源码安装MySQL8.0
129 0
|
12月前
|
关系型数据库 MySQL
麒麟系统源码安装mysql
麒麟系统源码安装mysql
102 0
|
关系型数据库 MySQL 数据安全/隐私保护
源码安装MySQL8.0 2
源码安装MySQL8.0
|
关系型数据库 MySQL Linux
阿里云linux源码安装mysql
阿里云linux源码安装mysql
|
存储 关系型数据库 MySQL
源码安装MySQL-5.7.38的脚本
源码安装MySQL-5.7.38的脚本
195 1
|
关系型数据库 MySQL Linux
linux(Centos)源码包安装 mysql-5.7.20.tar.gz
linux(Centos)源码包安装 mysql-5.7.20.tar.gz
261 0
linux(Centos)源码包安装 mysql-5.7.20.tar.gz
|
存储 Oracle 关系型数据库
MySQL源码安装
mysql是一个开源的关系型数据库管理系统,现在是oracle公司旗下的一款产品,由C和C++语言编写,可移植性高。 支持在多种操作系统上安装,最常见有AIX,linux,window。mysql因为开源免费,所以受到了目前互联网行业的 欢迎。 以mysql作为数据库,linux系统作为操作系统,apache或者nginx作为web服务器,perl/php/python作为服务 端的脚本解释器,就可以搭建起一个免费的网站。被业界称为LNMP或者LAMP
206 0
|
Ubuntu 关系型数据库 MySQL
linux篇-linux mysql5.6.27源码安装和错误解决
linux篇-linux mysql5.6.27源码安装和错误解决
504 0
linux篇-linux mysql5.6.27源码安装和错误解决

热门文章

最新文章