TheUnreal
TheUnreal

Reputation: 24492

Using vagrant ssh to edit mysql config on Windows

How I can change my /etc/mysql/my.cnf file and add sql-mode="allow_invalid_dates" in n y vagrant ssh command after connecting?

I tried to run vi /etc/mysql/my.cnf which opens the file, but not option to save it after editing..

Upvotes: 2

Views: 784

Answers (1)

Frederic Henri
Frederic Henri

Reputation: 53783

You can run a vagrant shell provisioner

Vagrant.configure("2") do |config|
  ...
  config.vm.provision "shell", inline: "echo 'sql-mode=\"allow_invalid_dates\"' >> /etc/sysconfig/configfile"
  ...
end

This will run it automatically for you

If you want to do from the vm and edit the file yourself, make sure you do as sudo and from vi do the following:

  • type ":$" to get to the end of the file
  • type ":i" to get into insert mode
  • type want you want, when you're done type ESC
  • type ":wq" to write and quit

I'm sure you can find plenty of tutorial on vi

Upvotes: 1

Related Questions