PowerShell install 一键部署mariadb10.11

news/2024/11/17 0:24:26/

mariadb

MariaDB数据库管理系统是MySQL的一个分支,主要由开源社区在维护,采用GPL授权许可 MariaDB的目的是完全兼容MySQL,包括API和命令行,使之能轻松成为MySQL的代替品。在存储引擎方面,使用XtraDB来代替MySQL的InnoDB。 MariaDB由MySQL的创始人Michael Widenius主导开发,他早前曾以10亿美元的价格,将自己创建的公司MySQL AB卖给了SUN,此后,随着SUN被甲骨文收购,MySQL的所有权也落入Oracle的手中。MariaDB名称来自Michael Widenius的女儿Maria的名字。

download mariadb

mariadbmariadb(RPM)mysql workbench文档

download

官网download

参考

参考

前提条件

  • 开启wmi,配置网卡,参考 

mariadb 10.11 一键自动化部署编写

  • 最终实现在线下载mariadb二进制包,解压重命名,创建数据目录,创建数据配置my.ini环境变量设置,初始化数据库,创建库,创建用户,创建用户权限,远程连接设置,版本获取,安装完成删除包,防火墙设置。
  • C:\mariadb 安装位置
  • C:\mariadb\data 数据目录
  • root/Report@123 mariadb数据库登录管理员
  • mar/Report@123 此账号是自定义创建的管理员,生产环境删除哦
  • mariadb_test 创建的临时数据库
  • C:\mariadb\data\my.ini 数据库配置文件
  • mysqldump.exe -uroot -pReport@123 --lock-all-tables --all-databases --events > c:\mysql_dump.sql 备份数据库操作
  • mysql -u root -pReport@123 < c:\mysql_dump.sql 导入数据库
  • mysql_install_db.exe 安装参数参考
  • if 判断是否存在psql 命令 if (-not (Get-Command mysql -ErrorAction SilentlyContinue)) 
  • 依赖VisualC++ ,所有包含历史版下载
  • increase indent:Tab
  • decrease indent:Shift+Tab
powershell-install-mariadb.ps1
<# Powershell Install mariadb
+++++++++++++++++++++++++++++++++++++++++++++++++++++
+  _____                       _____ _          _ _ +
+ |  __ \                     / ____| |        | | |+
+ | |__) |____      _____ _ _| (___ | |__   ___| | |+
+ |  ___/ _ \ \ /\ / / _ \ '__\___ \| '_ \ / _ \ | |+
+ | |  | (_) \ V  V /  __/ |  ____) | | | |  __/ | |+
+ |_|   \___/ \_/\_/ \___|_| |_____/|_| |_|\___|_|_|+
+ +++++++++++++++++++++++++++++++++++++++++++++++++++# mysql_install_db.exe install Basic
https://mariadb.com/kb/en/mysql_install_dbexe/# Powershell Install mariadb
# .\powershell-install-mariadb.ps1
#> function Install-mariadb {if (-not (Get-Command mysql -ErrorAction SilentlyContinue)) {if ($?) {$drive = "c:"$mariadb_temporary = "mariadb_temporary"$mariadb = "mariadb"$mariadb_data = "data"#mariadb configuration files$mysql_root_password = "Repot@123"$mysql_port = "3306"$mysql_my_ini = "my.ini"$mysql_socket = "mysql.sock"#mariadb packag$mariadb_zip = "mariadb-10.11.3-winx64.zip"$vc_redist_64 = "vc_redist.x64.exe"$vc_redist_86 = "vc_redist.x86.exe"$mariadb_decompression_directory = "mariadb-10.11.3-winx64"Write-Host "Create a directory for storing mariadb temporary" -ForegroundColor GreenNew-Item -ItemType Directory $drive\$mariadb_temporary$mariadb_related_download = @("https://archive.mariadb.org/mariadb-10.11.3/winx64-packages/$mariadb_zip","https://aka.ms/vs/17/release/$vc_redist_64","https://aka.ms/vs/17/release/$vc_redist_86")foreach ($url in $mariadb_related_download) {$fileName = Split-Path $url -Leaf$filePath = Join-Path $drive\$mariadb_temporary $fileNameInvoke-WebRequest -Uri $url -OutFile $filePath
}Write-Host "install vc_redist x86 x64" -ForegroundColor GreenStart-Process -FilePath "$drive\$mariadb_temporary\$vc_redist_64" -ArgumentList {/q /install} -WaitStart-Process -FilePath "$drive\$mariadb_temporary\$vc_redist_86" -ArgumentList {/q /install} -WaitWrite-Host "Unzip the mariadb package" -ForegroundColor GreenExpand-Archive -Path $drive\$mariadb_temporary\$mariadb_zip -DestinationPath $drive\Write-Host "Rename the mariadb folder name" -ForegroundColor GreenRename-Item -Path $drive\$mariadb_decompression_directory -NewName $mariadbWrite-Host "Create a directory for storing database data" -ForegroundColor GreenNew-Item -ItemType Directory "$drive\$mariadb\$mariadb_data"Write-Host "Create mariadb environment variables" -ForegroundColor Green$env:path += ";$drive\$mariadb\bin"setx PATH $env:path /MWrite-Host "mysql ini configuration" -ForegroundColor Green
$functionText = @"
[client]
port=$mysql_port
plugin-dir=$drive\$mariadb\lib\plugin
default-character-set=utf8mb4[mysqld]
datadir=$drive\$mariadb\$mariadb_data
basedir=$drive\$mariadb
port=$mysql_port
max_connections=200
character_set_server=utf8mb4
collation-server=utf8mb4_unicode_ci
character-set-client-handshake=FALSE
default-storage-engine=INNODB
default-time_zone='+8:00'
log_bin_trust_function_creators = on
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
lower_case_table_names=1[mysql]
default-character-set=utf8mb4
"@New-Item "$drive\$mariadb\$mysql_my_ini" -type file -force -value $functionTextWrite-Host "initialize mariadb" -ForegroundColor Greenmysql_install_db --config=$drive\$mariadb\$mysql_my_ini --datadir=$drive\$mariadb\$mariadb_data --socket=$mysql_socket --service=$mariadb --password=$mysql_root_passwordWrite-Host "start mariadb" -ForegroundColor GreenStart-Service $mariadbWrite-Host "Viewing mysql process port" -ForegroundColor Greennetstat -ano|findstr $mysql_portTest-NetConnection -ComputerName localhost -Port $mysql_port | Select-Object -ExpandProperty TcpTestSucceededGet-Service -Name $mariadb | Select-Object -ExpandProperty StatusWrite-Host "check mariadb version" -ForegroundColor Greenmysql -VWrite-Host "Allow root to log in remotely" -ForegroundColor Greenmysql -uroot -p$mysql_root_password -e "GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'Report@123' WITH GRANT OPTION;"Write-Host "Create a user and assign the user login permission, super user permission, super role permission, database creation permission, replication permission, and backup permission" -ForegroundColor Greenmysql -uroot -p$mysql_root_password -e "CREATE DATABASE mariadb_test;"mysql -uroot -p$mysql_root_password -e "CREATE USER mar@'%' IDENTIFIED BY 'Report@123';"mysql -uroot -p$mysql_root_password -e "GRANT ALL PRIVILEGES ON *.* TO mar@'%' WITH GRANT OPTION;"mysql -uroot -p$mysql_root_password -e "GRANT SUPER ON *.* TO mar@'%';"Write-Host "firewall mariadb port" -ForegroundColor GreenNew-NetFirewallRule -DisplayName $mariadb -Direction Outbound -profile any -LocalPort $mariadb_port -Protocol TCP -Action AllowNew-NetFirewallRule -DisplayName $mariadb -Direction Inbound -profile any -LocalPort $mariadb_port -Protocol TCP -Action AllowWrite-Host "Delete related mariadb packages and temporary directories" -ForegroundColor GreenRemove-Item -Path "$drive\$mariadb_temporary\*.exe", "$drive\$mariadb_temporary", "$drive\$mariadb\$mysql_my_ini" -Recurse -ForceWrite-Host "The mariadb Install Success..." -ForegroundColor Green} else {Write-Host "The mariadb Install Failed..." -ForegroundColor Redexit 1}} else {Write-Host "The mariadb Install already..." -ForegroundColor Yellow}
}function Main {Install-mariadb
}Main

执行安装mariadb

.\powershell-install-mariadb.ps1

输出结果展示

 


http://www.ppmy.cn/news/240339.html

相关文章

VTK学习之vtkProp

vtkProp。渲染场景中数据的可视表达&#xff08;Visible Depictions&#xff09;是由vtkProp的子类负责。 也就是说&#xff0c;数据想要进行可视化显示&#xff0c;需要一个转换过程&#xff0c;这个过程就是转换为vtkProp 这样才能进行渲染展示出来。 而vtkProp子类是vtkA…

【GreendDao 】RxQuery根据指定条件查询,完成后处理UI逻辑

GreenDao 和 RxJava 结合使用可以更方便地处理数据查询和 UI 逻辑的交互。RxQuery 使得一次查询结果可以直接转化成 Observable&#xff0c;而通过 RxJava 的操作符&#xff0c;可以方便地完成异步查询和 UI 逻辑的交互。以下是一个根据指定条件查询数据&#xff0c;查询完成后…

Android万能播放器

Android万能播放器 0.eclipse直接导入即可食用&#xff08;亲&#xff0c;有两个是库工程哦&#xff09; 1.基于Vitamio的万能播放器&#xff08;自己百度哈&#xff09; 2.扫描本地视频&#xff0c;获取每个视频第一帧&#xff0c;并显示 3.手势控制音量、亮度 4.获取到的…

万能格式音视频播放器KMPlayer Plus (Divx)_31.02.100Pro版

Pro版由就要分享网91apps.cn的SOLDIER分享&#xff0c;谈到音视频播放器软件&#xff0c;大家一定会记得昔日的王者——KMplayer&#xff01;对&#xff0c;你没看错&#xff0c;曾经在 Windows 上有着霸主地位的万能格式音视频播放器。KMPlayer Mobile (移动版)和PC版一样同样…

android能播放4k视频格式,安卓APP,无广告支持多种格式的万能视频播放器

原标题&#xff1a;安卓APP&#xff0c;无广告支持多种格式的万能视频播放器 万能视频播放器 万能视频播放器是一款专业的视频播放工具。它支持所有视频格式&#xff0c;支持 4K/超高清视频文件&#xff0c;并且能够高清播放。它是安卓手机和平板上欣赏影片的最佳选择。万能播放…

2021年真正强大、最值得推荐的的视频播放器(全平台)

2021年真正强大、最值得推荐的的视频播放器&#xff08;全平台&#xff09; 1.MacOS最强视频播放器 IINA: https://iina.io 2.Windows系统上最好用的视频播放器 PotPlayer: https://potplayer.daum.net VLC: https://www.videolan.org KMPlayer: https://www.kmplaye…

推荐四款非常好用的免费音乐播放器

不知道大家在工作的时候&#xff0c;是不是跟我一样&#xff0c;喜欢听着自己熟悉的旋律&#xff0c;心情也会很好。 但是&#xff0c;原来的很多经典歌曲&#xff0c;要么改收费一首歌几块钱、要么是翻唱的&#xff0c;听起来也没有原版好&#xff0c;对于我们这些只是偶尔听…

推荐一个【好用的】【免费的】【视频】【播放器】【potplayer】

官方网站&#xff1a; http://potplayer.daum.net/?langzh_CN PotPlayer PotPlayer 是 KMPlayer 的原制作者姜龙喜先生&#xff08;韩国&#xff09;进入 Daum 公司后的新一代网络播放器。PotPlayer 的优势在于强大的内置解码器&#xff1b;而 KMPlayer 的优势在于强大的定制能…