Silent Installation of MySQL (version 5.7) on Windows with Batch Files - mysql

i'm trying to create a setup process for my C# application that use MySQL Database local (not online, every PC that will install my app, will get a clean Database to use). Searching around google i found that i need to make a "Silent" install of MySQL required components which are:
MySQL Server 5.7
MySQL Connector/Net
So I've done the following steps:
1) Downloading mysql-installer-community-5.7.11.0.msi from MySQL Home page
2) Made a Batch file "Setup.bat" that will create a Folder C:\MySQL and Copy there the Installer.msi and another batch file "Installer.bat".
3) After copying start Installer.bat with the command
Call C:\MySQL\Installer.bat
4) What Installer.bat will do:
#echo off
echo.
set password=admin
set installer="C:\Program Files (x86)\MySQL\MySQL Installer for Windows\MySQLInstallerConsole.exe"
set version=5.7.11
echo -----------------------
echo Details
echo -----------------------
echo Server User: root
echo.
echo Server Password: %password%
echo.
echo Configuration Folder: %installer%
echo.
echo Version: %version%
echo -----------------------
echo Start Installation... (si prega di attendere alcuni minuti)
echo.
msiexec /i "%~dp0\mysql-installer-community-%version%.0.msi" /qb
%installer% community install server;%version%;X64:*:port=3307;openfirewall=true;passwd=%password% -silent
pause
Installing the .msi file inside the folder,
Download and Install the MySQL server 5.7
and from here start my problem, the Download and Installation of MySQL server 5.7 go well, but once it need to configure with my parameters it start to initilazie the server with several steps:
Stopping Server [If Necessary]
Writing Configuration file
Updating Firewall
... and so on till i get this one
Starting Server
Once there it will never complete, so I checked Windows Event Viewer and i found that two errors occur once the " Starting Server " step begin:
Error1 Failed to create datadir C:\Program Files\MySQL\MySQL Server 5.7\data
Then
Error2 Aborting
If i try to install those components manually with the GUI installer i don't get any error and everything works good, but i need to make them install and configure automatically, can someone help me please? (Sorry about my english)

Related

Error while running mysql_secure_installation on arch linux

I'm trying to install MySQL(pure) on Arch Linux so I downloaded the following file from https://dev.mysql.com/downloads/mysql/.
mysql-8.0.26-linux-glibc2.17-x86_64-minimal-rebuild.tar.xz
I extracted it and tried to run ./mysql_secure_installation but after I enter the root password I get the following error message:
[rob#archrob bin]$ sudo ./mysql_secure_installation
Securing the MySQL server deployment.
Enter password for user root:
Error: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
How can I fix this?
I tried to download it from AUR repository too but when I run the makepkg -si it get a point of the installation it looks like will take forever.
Build files have benn written to /home/rob/mysql/src/build
[0%] Built target INFO_BIN
[0%] built target abi_check
[0%] built target INFO_SRC
[0%] Building CXX object extra/protobuf...
[0%] and so on...
After one hour it was at [22%] so I stopped the installation and tried from the official website.
You'll need to start mariadb before running mysql_secure_installation:
$ sudo systemctl start mariadb.service

How can I set the my.ini location at install time

I have an application with a NSIS installer, it installs my application and also mysql 5.7.25.
When installing it create a my.ini inside :
C:\ProgramData\MySQL\MySQL Server 5.7
The problem is that one of my client has another application which run with mysql 5.7.20. which also has a my.ini in the same place. So my installer overwrite the existing file and break the other app.
When installing how can I tell the installer where the my.ini is ?
My idea is to put it inside my application folder and tell mysql to look here:
C:\ProgramData\MyAPP
I am installing mysql like that (in 2 steps):
I install the installer :
"msiexec" /quiet /norestart /i
"C:\MYAPP\Mysql\mysql-installer-community-5.7.25.0.msi"
INSTALLDIR="C:\Program Files\MySQL\MySQL Server 5.7"
then mysql
"C:\Program Files (x86)\MySQL\MySQL Installer for
Windows\MySQLInstallerConsole.exe" community install -silent
server;5.7.25;x64:*:port=3306;passwd=root;installdir="C:\Program
Files\MySQL\MySQL Server 5.7"
Thanks
Ok I found the solution :
I believed that mysql installation was creating the service. But I was wrong the windows service is created later in my installer :
'"$1\bin\mysqld.exe" --install ${MYSQL_SERVICE_64}'
So can add the argument "--defaults-file" here and place the .ini where ever I want.

FreeBSD MySQL error after installation

I am on FreeBSD 10.2 32 bit and installed the newest version of mysql with the following command:
pkg install mysql57-server-5.7.12
Now, when I try to start mysql:
service mysql-server start
/usr/local/etc/rc.d/mysql-server: WARNING: failed precmd routine for mysql
I am getting this error. I hope you can help me.
Check your /var/db/mysql folder, if it contains files, make a backup and delete dir content:
rm -rf /var/db/mysql/*
Then do a data directory initialization:
/usr/local/libexec/mysqld --initialize --user=mysql
You should get a new temporary password, write it down, then start mysql-server
service mysql-server start
After mysql starts, secure the installation via:
/usr/local/bin/mysql_secure_installation
Open /etc/rc.conf and append or modify this line :
mysql_enable="YES"
Save the file, close it and retry to start the server.

Install MySQL Community 5.6.14 in Passive mode using batch file (on win7)

I'm trying to install MySQL Community 5.6.14 in Passive mode using a batch file.
First of all "MySQLInstaller" is unable to install MySQL in passive or quiet mode and user has to complete the installation wizard manually!
Does MySQL Community 5.6.14 support passive (or quiet) mode?!
Secondly, I have tested MySQLInstallerConsole examples but I couldn't find a correct combination of parameters !!!
Batch File Content:
#Echo off
echo Installing MysqlInstaller....
msiexec /i "c:\mysql\mysql.msi" /passive
cd C:\Program Files\MySQL\MySQL Installer
echo Config MysqlServer....
MySQLInstallerConsole --type=developer --action=install --product=* --config=mysql-server-5.6.14-win32:passwd=apassword
echo Finished !
pause
you can get the help by typing:
MySQLInstallerConsole.exe install
try this:
MySQLInstallerConsole.exe install server;5.6.17:*:port=3306;serverid=2:type=user;username=foo;password=bar;role=DBManager
I hope this will help.

MySQL Homebrew Warning: m4 macros were installed to "share/aclocal"

Received this warning when installing MySQL:
Warning: m4 macros were installed to "share/aclocal".
Homebrew does not append "/usr/local/share/aclocal"
to "/usr/share/aclocal/dirlist". If an autoconf script you use
requires these m4 macros, you'll need to add this path manually.
Managed to start MySQL in safe mode using:
# cd . ; ./bin/mysqld_safe &
However, I can't start the server normally by trying:
# mysql.server start
Starting MySQL
. ERROR! The server quit without updating PID file (/usr/local/var/mysql/robell.local.pid).
Also noticed that this file doesn't exist:
# launchctl load -w /usr/local/Cellar/mysql/5.5.19/com.mysql.mysqld.plist
launchctl: Couldn't stat("/usr/local/Cellar/mysql/5.5.19/com.mysql.mysqld.plist"): No such file or directory
nothing found to load
brew info mysql
will list a few steps that are required prior to starting the server, due to the subtleties of permissions and how Homebrew never uses sudo. Good luck.