本文目标

制作一个MySQL8的绿色版,以后解压即用,方便进行测试部署。
默认用户名root,密码root,仅限本机登录
默认用户名test,密码test,任意机器登录
默认数据库test
注意弱口令风险

下载原版MySQL8

mysql-8.0.31-el7-x86_64.tar.gz
https://dev.mysql.com/downloads/mysql/

解压文件

tar xfz mysql-8.0.31-el7-x86_64.tar.gz
drwxr-xr-x.  2 yinyx yinyx   4096 Dec  2 07:09 bin
drwxr-xr-x.  2 yinyx yinyx     55 Sep 14 01:50 docs
drwxr-xr-x.  3 yinyx yinyx   4096 Sep 14 01:50 include
drwxr-xr-x.  6 yinyx yinyx    201 Sep 14 01:50 lib
-rw-r--r--.  1 yinyx yinyx 287627 Sep 14 00:15 LICENSE
drwxr-xr-x.  4 yinyx yinyx     30 Sep 14 01:50 man
-rw-r--r--.  1 yinyx yinyx    666 Sep 14 00:15 README
drwxr-xr-x. 28 yinyx yinyx   4096 Sep 14 01:50 share
drwxr-xr-x.  2 yinyx yinyx     77 Sep 14 01:50 support-files

文件瘦身

进入bin目录执行

[yinyx@localhost bin]$ strip *
strip:mysql_config: File format not recognized
strip:mysqld_multi: File format not recognized
strip:mysqld_safe: File format not recognized
strip:mysqldumpslow: File format not recognized
[yinyx@localhost bin]$ du -sh *
6.5M    ibd2sdi
6.4M    innochecksum
6.3M    lz4_decompress
6.6M    myisamchk
6.5M    myisam_ftdump
6.5M    myisamlog
6.5M    myisampack
6.3M    my_print_defaults
7.5M    mysql
7.2M    mysqladmin
7.6M    mysqlbinlog
7.2M    mysqlcheck
8.0K    mysql_config
6.3M    mysql_config_editor
61M mysqld
104M    mysqld-debug
28K mysqld_multi
32K mysqld_safe
7.3M    mysqldump
8.0K    mysqldumpslow
7.2M    mysqlimport
7.3M    mysql_migrate_keyring
7.8M    mysqlpump
7.2M    mysql_secure_installation
7.2M    mysqlshow
7.2M    mysqlslap
6.3M    mysql_ssl_rsa_setup
6.2M    mysql_tzinfo_to_sql
7.3M    mysql_upgrade
7.0M    perror
6.2M    zlib_decompress
[yinyx@localhost bin]$ pwd
/home/yinyx/mysql-8.0.31-el7-x86_64/bin
[yinyx@localhost bin]$ rm -f mysqld-debug

strip 是用来清除C程序调试信息的。
mysqld-debug是调试MySQL用的,平时用不到,并且很大,删除掉。

初始化数据库

./bin/mysqld --defaults-file=./my.cnf --initialize-insecure --basedir="./" --datadir="./data" --socket="./bin/mysql.sock" --pid-file="./bin/mysql.pid" --console
2022-12-01T23:25:46.849158Z 0 [Warning] [MY-010139] [Server] Changed limits: max_open_files: 1024 (requested 9010)
2022-12-01T23:25:46.849166Z 0 [Warning] [MY-010141] [Server] Changed limits: max_connections: 214 (requested 1000)
2022-12-01T23:25:46.849174Z 0 [Warning] [MY-010142] [Server] Changed limits: table_open_cache: 400 (requested 4000)
2022-12-01T23:25:46.852398Z 0 [Warning] [MY-010918] [Server] 'default_authentication_plugin' is deprecated and will be removed in a future releuse authentication_policy instead.
2022-12-01T23:25:46.852425Z 0 [System] [MY-013169] [Server] /home/yinyx/mysql-8.0.31-el7-x86_64-green/bin/mysqld (mysqld 8.0.31) initializing oprogress as process 19432
2022-12-01T23:25:46.887651Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2022-12-01T23:25:47.547489Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2022-12-01T23:25:49.142124Z 6 [Warning] [MY-010453] [Server] root@localhost is created with an empty password ! Please consider switching off tize-insecure option.

配置my.cnf

[mysqld]
# 设置3306端口
port=3306
# 设置mysql的安装目录
basedir=/usr/local/mysql
# 设置mysql数据库的数据的存放目录
datadir=/usr/local/mysql/mysqldb
# 允许最大连接数
max_connections=1000
# 允许连接失败的次数。这是为了防止有人从该主机试图攻击数据库系统
max_connect_errors=100
# 服务端使用的字符集默认为UTF8
character-set-server=utf8mb4
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB
# 默认使用“mysql_native_password”插件认证
default_authentication_plugin=mysql_native_password
#是否对sql语句大小写敏感,1表示不敏感
lower_case_table_names = 1
#MySQL连接闲置超过一定时间后(单位:秒)将会被强行关闭
#MySQL默认的wait_timeout  值为8个小时, interactive_timeout参数需要同时配置才能生效
interactive_timeout = 1800
wait_timeout = 1800
#Metadata Lock最大时长(秒), 一般用于控制 alter操作的最大时长sine mysql5.6
#执行 DML操作时除了增加innodb事务锁外还增加Metadata Lock,其他alter(DDL)session将阻塞
lock_wait_timeout = 3600
#内部内存临时表的最大值。
#比如大数据量的group by ,order by时可能用到临时表,
#超过了这个值将写入磁盘,系统IO压力增大
tmp_table_size = 64M
max_heap_table_size = 64M
[mysql]
# 设置mysql客户端默认字符集
default-character-set=utf8mb4
[client]
# 设置mysql客户端连接服务端时默认使用的端口
port=3306
default-character-set=utf8mb4

配置启停脚本

上传mysql的shell文件后执行:

[yinyx@localhost mysql-8.0.31-el7-x86_64-green]$ ./mysql start
Starting MySQL ... SUCCESS!
[yinyx@localhost mysql-8.0.31-el7-x86_64-green]$ netstat -lntp
(Not all processes could be identified, non-owned process infowill not be shown, you would have to be root to see it all.)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      -
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      -
tcp6       0      0 ::1:25                  :::*                    LISTEN      -
tcp6       0      0 :::6306                 :::*                    LISTEN      19900/mysqld
tcp6       0      0 :::33060                :::*                    LISTEN      19900/mysqld
tcp6       0      0 :::22                   :::*                    LISTEN      -

进入MySQL命令行,修改数据库默认设置

./bin/mysql  --defaults-file=./my.cnf --socket=./data/mysql.sock -h localhost -u root -p

默认密码为空,回车直接进入MySQL命令行

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'root';
Query OK, 0 rows affected (0.00 sec)mysql> CREATE DATABASE test;
Query OK, 1 row affected (0.01 sec)mysql> create user 'test'@'%' identified by 'test';
Query OK, 0 rows affected (0.01 sec)mysql> grant all on *.* to 'test'@'%';
Query OK, 0 rows affected (0.01 sec)mysql> 

创建cmd.sh

[yinyx@localhost mysql-8.0.31-el7-x86_64-green]$ cat cmd.sh./bin/mysql  --defaults-file=./my.cnf --socket=./data/mysql.sock -h localhost -u test -ptest test[yinyx@localhost mysql-8.0.31-el7-x86_64-green]$ ./cmd.sh
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 8.0.31 MySQL Community Server - GPLCopyright (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> 

停止数据库

./mysql stop

打包绿色版

tar cfz mysql-8.0.31-el7-x86_64-green.tar.gz mysql-8.0.31-el7-x86_64-green

制作轻量版

删除bin目录不常用工具,只保留
mysqld --主程序
mysqld_safe --启动shell
mysql --命令行客户端
my_print_defaults --启动使用
mysqldump --备份数据库

总结

[yinyx@localhost ~]$ du -sh *
945M    mysql-8.0.31-el7-x86_64
493M    mysql-8.0.31-el7-x86_64.tar.gz
663M    mysql-8.0.31-el7-x86_64-green
158M    mysql-8.0.31-el7-x86_64-green.tar.gz
357M    mysql-8.0.31-el7-x86_64-lite
56M mysql-8.0.31-el7-x86_64-lite.tar.gz

原版493MB

green版158MB,功能一个没少,只是体积变小了,并且带了初始化好的data数据库

lite版56MB,作为测试环境Server已经够用了,数据库启停相关功能都有,只是缺少解决数据库异常情况下的相关工具。

1 MySQL8绿色版相关推荐

  1. mysql8 绿色版安装

    参考:https://www.jb51.net/article/140412.htm https://blog.csdn.net/wallezhou/article/details/81481457 ...

  2. 制作mysql8.0.22 绿色版

    一.下载mysql压缩包, 下载网址 :https://downloads.mysql.com/archives/community/ 当前最新版本为8.0.22 , 我们选择Linux - Gene ...

  3. 绿色版NVM安装与配置详细说明

    绿色版本(不需要安装,直接解压,然后配置环境变量等) 由于最初发布的nvm并不支持window,所以如果希望可以像在*nix上一样控制node的版本,有两种选择: nvm-windows nodist ...

  4. 系统清理工具(Wise Care 365)绿色版

    2019独角兽企业重金招聘Python工程师标准>>> Wise Care 365 具有强大的多分类"系统清理"功能模块,找准了您想要清理的垃圾或者冗余,安全性不 ...

  5. 图解eclipse+myeclipse完全绿色版制作过程

    现在在Java开发中,使用的开发工具大部分都是Eclipse,并且和Eclipse关系紧密的要数MyEclipse了,但是 MyEclipse是一个EXE可执行程序,对于没有安装Eclipse与MyE ...

  6. 安装、设置与启动MySql5.1.30绿色版的方法

    1.解压 mysql-noinstall-5.1.30-win32.zip(下载地址http://dev.mysql.com/downloads/mysql/5.1.html) 2.在 F 盘建立目录 ...

  7. android c/c++ eclipse 绿色版 环境的配置

    一:阅读前的准备条件 1:目的,android 高性能方面的开发 2:条件:liunx系统熟悉,c/c++ 熟悉,Java 熟悉,Eclipse 开发工具熟悉,JNI 调用方式熟悉,熟悉面向对象的程序 ...

  8. 添加绿色版UltraEdit到右键菜单

    添加绿色版UltraEdit到右键菜单 最近重新安装了系统,由于新下载的UltraEdit是绿色版本的,故在右键菜单中不会显示,用起来实在麻烦. 无奈之下,网上搜索出几个手动添加的办法,试用了下,感觉 ...

  9. mysql绿色版的应用5.7

    一.配置MySQL数据库 1.解压绿色版mysql,并改名为mysql5.7,如下图 对比一下下图5.6以前的版本,少data目录(存放数据)和my-default.ini文件(配置信息) 二.安装服 ...

最新文章

  1. 机器学习数据不平衡不均衡处理之SMOTE算法实现
  2. pyspark导出文件
  3. LVS TUN模式搭建
  4. Java访问指示符 访问修饰符
  5. 如何将文件拷贝服务器上,如何将文件复制到云服务器上
  6. 微信小程序之自定义toast弹窗
  7. 111 进程的创建和结束
  8. 机器学习- 吴恩达Andrew Ng Week7 知识总结Support Vector Machines
  9. 硬件知识:固态硬盘和机械硬盘区别
  10. 只利用 phpstudy 如何运行PHP文件 超详细教程
  11. 美国留学访学(访问学者)必备信用卡
  12. 投掷骰子的python代码_模拟骰子(Python),掷骰子
  13. Win10以太网网络电缆被拔出怎么解决
  14. 我涉及的数据可视化的实现技术和工具
  15. Visual Studio 2010——C#的主菜单的使用
  16. IDA PRO:庆祝成立创新 30 周年
  17. java开发面试自我介绍模板_java求职自我介绍范文_java工程师面试个人介绍
  18. 对字下面添加下划虚线
  19. Moodle专题网站链接
  20. django ajax页面跳转,Django中的AJAX GET请求后重定向

热门文章

  1. nested exception is org.springframework.core.serializer.support.SerializationFailedException异常解决
  2. 招商银行2022FinTech数据赛道总结
  3. 计算机视觉之图像检索
  4. 用C++实现一个小小的爬虫
  5. 项目管理(如何进行项目风险管理)
  6. 《硝烟中的scrum和xp》读书笔记
  7. matlab霍夫曼图像压缩,用matlab仿真huffman编码在jpg图像压缩中的应用崔微微
  8. 地图兴趣点搜索一(基本流程)
  9. day11函数进阶作业
  10. rstudio找不到r低版本_R语言安装新版本后旧版本安装包的迁徙问题