vagrant upコマンドを実行するだけで、CentOS8.1でMySQL8.0がすぐに利用できるようになるVagrantfileです。(macOSで動作確認しています)
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "bento/centos-8.1"
config.vm.box_check_update = false
config.vm.network "forwarded_port", guest: 3306, host: 3306
#config.vm.synced_folder "../data", "/vagrant_data"
#config.vm.provider "virtualbox" do |vb|
# vb.gui = true
# vb.memory = "1024"
#end
config.vm.provision "shell", inline: <<-SHELL
# install MySQL server.
sudo yum install mysql-server -y
# start and enable mysqld.
systemctl start mysqld
systemctl enable --now mysqld
systemctl status mysqld
# add grant through vagrant gateway
mysql -u root -e "create user 'root'@'_gateway' identified by '';"
# check version.
mysql --user=root --password='' --execute 'select version();'
SHELL
end
上記のファイルをコピーした上で、'vagrant up'するだけで、MySQL8.0.xがインストール済みのVMがローカルで起動できます。
起動後はホストOSから下記のコマンドをでサーバに接続できます。
$ mysql --host=127.0.0.1 --user=root --password='' --execute 'select version();'
mysql: [Warning] Using a password on the command line interface can be insecure.
+-----------+
| version() |
+-----------+
| 8.0.17 |
+-----------+
こちらもおススメ