MySql silent installation /qn not working - mysql

I am using below code to install mysql silently on windows using a batch file..
Seems like it is ignoring /qn
also i have tried with /quiet but that is also not working.
it is just reading line and moving cursor to next line.
echo off
cls
echo Starting MySQL mysql-essential-5.0.88-win32 install
msiexec /i "mysql-essential-5.0.88-win32.msi" /qn INSTALLDIR="C:\Program Files\MySQL" /L* "C:\Program Files\MySQL\mysql-log.txt"
echo MySQL mysql-essential-5.0.88-win32 installed successfully
echo Creating MySQL Windows service
"C:\Program Files\MySQL\bin\mysqlinstanceconfig.exe" -i -q ServiceName="MySQL service" RootPassword="newRootPassword" ServerType=SERVER DatabaseType=MYISAM Port=3306
RootCurrentPassword=mysql
echo MySQL Instance Configured. Service started.
pause
I have tried directly running command but it is completely ignoring
NOTE: Setup is working fine if i run it directly, issue is with silent installation only
please suggest.
thanks.

/ni
/q
/qn
/quiet
/s
/silent
Try dashes instead of forward slashes too (-S instead of /S), and check both upper case and lower case.
Hope that helps.

#Echo off
FOR /F "tokens=5" %%a in ('netstat -aon ^| find "3306" ^| find "LISTENING"') do taskkill /f /pid %%a
cls
TIMEOUT 1
if "%ProgramFiles(x86)%" == "" (
set "MySQLServerPath=%ProgramFiles%\MySQL\MySQL Server 5.0\bin"
) else (
set "MySQLServerPath=%ProgramFiles(x86)%\MySQL\MySQL Server 5.0\bin"
)
REM echo Configurating MySQL Server ...
"%MySQLServerPath%\MySQLInstanceConfig.exe" -i -q ServerType=DEVELOPER ConnectionUsage=DSS Port=3306 StrictMode=yes Charset=utf8 DatabaseType=MIXED ServiceName=root RootPassword=root
REM echo MySQL has been configured successfully.

Related

What command does XAMPP use to start MySQL?

To start a MySQL (technically mariadb) module from the XAMPP control panel, you just click the "Start" action button. What command is being run behind the scenes for "Start"? I've tried to replicate it from the command line with a variety of commands, but I've found that the "Start" button will succeed where my command-line commands fail.
The net start and net stop commands from a command line will start and stop services including of course MySQL or MariaDB.
net start mariadb
basically
mysqld.exe --defaults-file="C:\ammpp\my.ini"
mysqld is the server command
the my.ini ist the configuration you have to check the folder
And MySQL80 is the name
see manual for more options
As the github says is the command line in the batch file xampp/mysql_start.bat `
mysql\bin\mysqld --defaults-file=mysql\bin\my.ini --standalone --console
the my.ini makes some minor changes to the default values, no trickery at all
I have no idea what trickery the XAMPP package uses, but if you want to start the mariadb service from the cmd, all you need is an elevated command prompt and the following line:
net start MariaDB
Note: my OS is Win10
A modification of nbk's answer worked for me in PowerShell:
C:\xampp\mysql\bin\mysqld.exe --defaults-file="C:\xampp\mysql\bin\my.ini" --console
This shows up as running in the XAMPP Control Panel (v3.2.4) and uses the correct port from the my.ini file (I'm using port 3308).
To stop the MySQL server, you can hit Ctrl+C, but only if the MySQL server is open with the --console param. To stop it from another terminal I've tried various shutdown commands, but none have worked for me so I've had to use the ugly command:
taskkill /FI "IMAGENAME eq mysqld.exe" /T /F
From a .bat batch file I've also found these commands useful for starting and stopping:
:: Start
start "XamppMySQLD1" powershell -NoExit -command "& 'C:\xampp\mysql\bin\mysqld.exe' --defaults-file='C:\xampp\mysql\bin\my.ini' --console" || echo ERROR && exit /b
:: Is it running? On the expected port?
tasklist | findstr /i "mysql"
netstat -ano | findstr 3308
:: Stop
taskkill /FI "WindowTitle eq XamppMySQLD*" /T /F

Unable to find the correct syntax for creating batch to dump each database into it's own .sql

I have been pouring through multiple forms and stack overflow questions looking for the correct syntax for creating a batch fill that will generate one .sql dump file for each database.
:: Name of the database user
set dbuser=user
:: Password for the database user
set dbpass=password
:: Loop through the data structure in the data dir to get the database names
"C:\Program Files\MySQL\MySQL Server 5.7\bin\mysql" -u%dbuser% -p%dbpass% -e "show databases" ^| FOR /D %%F IN (read databases) DO (
"C:\Program Files\MySQL\MySQL Server 5.7\bin\mysqldump" --user=%dbuser% --password=%dbpass% --databases %%F > "D:\Backup\%%F_6am_mon.sql"
)
Structure of code mainly came from Jon Lucas at http://kb.hyve.com/wiki/Backup%20All%20MySQL%20Databases%20and%20Output%20To%20Seperate%20Files
I had other code but this one seemed to write to a file.
I've code that works on non-windows, but I need something that will work in windows server 2008 R2 cmd
Can anyone shed some light for me?
ALSO TRIED------------
FOR /F "usebackq delims=" %%F IN ("C:\Program Files\MySQL\MySQL Server 5.7\bin\mysqldump" -u%user% -p%password% -e "show databases;") DO (
"C:\Program Files\MySQL\MySQL Server 5.7\bin\mysqldump" --user=%user% --password=%password% --databases %%F > "D:\Backup\%%F_6am_mon.sql"
)
If you can install Powershell then this script should work;
foreach ($i in Get-ChildItem -Path "c:\Users\jelemans\Documents" -Directory)
{
echo "backing up - $i.name"
$theDate = get-date -format yyyymmdd
$backupName = "backup$theDate"
backup($backupName)
}
Function backup($dbName)
{
$path = "D:backupPath$dbName"
mysqldump -uxxx -pyyy $dbName > $path
}
witht the correct path set for your db (not my test folder).
Try this script for unix;
for var in "$#"
do
echo "Backing up $var"
backupName=backup$var`date +'%Y%m%d'`
mysqldump --user=%user% --password=%password% $var > "\Backup\$backupName"
done
with the edits for your user and password.
Execute this to run it from the data directory (or add cd in the script);
find * -type d -exec testScript {} +
changing the name of "testScript" to match your script name. Note that this script will try to do mysql as well. you need a mod if you want to skip that one.

install mysql server on windows using batch script

I'm installing mysql on windows using batch script.
#echo off
echo Installing MySQL Server. Please wait...
msiexec /i "D:\MySQL\mysql-installer-community-5.6.34.0.msi" /qn /norestart
echo Configurating MySQL Server...
"%Program Files%MySQL\MySQL Server 5.6\bin\mysqlinstanceconfig.exe" -i -q ServiceName=MySQL RootPassword=mysql ServerType=DEVELOPER DatabaseType=MYISAM Port=3306 Charset=utf8
echo MySQL has been installed successfully
setx PATH "%%Program Files%\MySQL\MySQL Server 5.5\bin%;"
pause
cd /
c:
mysql --user=root --password=mysql -e "CREATE USER 'myuser'#'localhost' IDENTIFIED BY 'user1';"
;
mysql --user=root --password=mysql -e "GRANT ALL ON mydatabase.* TO 'myuser'#'%' IDENTIFIED BY 'user1' WITH GRANT OPTION;
In the above script any mistake is there.I am getting the error.
"The system cannot find the path specified"
This following script seems to work for me. I just removed the spaces between %Program Files% and added a backward slash after %ProgramFiles%.
#echo off
echo Installing MySQL Server. Please wait...
msiexec /i mysql-5.5.25a-winx64.msi /passive
echo Configurating MySQL Server...
"%ProgramFiles%\MySQL\MySQL Server 5.5\bin\mysqlinstanceconfig.exe" -i -q
ServiceName=MySQL RootPassword=mysql ServerType=DEVELOPER DatabaseType=MYISAM
Port=3306 Charset=utf8
echo MySQL has been installed successfully
setx PATH "%ProgramFiles%\MySQL\MySQL Server 5.5\bin%;"
pause
P.S. Batch script and installer are present in the same folder.

Powershell command did not wait

I have following 2 commands in powershell script file, but second command did not wait till first command gets executed.
cmd.exe /c "msiexec /i c:\Temp\mysql.msi /quiet"
cd "C:\Program Files (x86)\MySQL\MySQL Installer for Windows"
note: first command installing mysql installer at location C:\Program Files (x86)\MySQL\MySQL Installer for Windows"...
In second command, i used cd to go to at directory C:\Program Files (x86)\MySQL\MySQL Installer for Windows"
Your PowerShell script does not know what the cmd.exe command is going to execute but it does wait for cmd.exe to finish.
The problem is that cmd.exe is not waiting for msiexec before returning.
If you wish to wait for msiexec to finish before moving on to your second command then call msiexec yourself using Start-Process with the -Wait parameter:
Start-Process -Wait -FilePath msiexec -ArgumentList "/i c:\Temp\mysql.msi /quiet"

How to install mysql from batch file?

I am working on java desktop application in which i use MYSQL database, but i have a problem , i want to embed MYSQL database, for this i want a script to install the MYSQL, i need Help to install MYSQL from batch file (windows).
i am using this script
#echo off
echo Installing MySQL Server. Please wait...
msiexec /i "mysql-installer-community-5.6.14.0.msi" /qn
echo Configurating MySQL Server...
"%ProgramFiles%\MySQL\MySQL Server 5.6\bin\mysqlinstanceconfig.exe"
-i -q ServiceName=MySQL RootPassword=mysql ServerType=DEVELOPER
DatabaseType=MYISAM Port=3306 Charset=utf8
echo Installation was successfully
i get the error,"The system cannot find the path specified".
Any help will be appreciated.
I suspect that %ProgramFiles% is pointing to the wrong folder.
Try #echo %ProgramFiles% from a file to see what folder it is looking in. You have to make sure that it is not in the Program Files x86 folder.
I found this link also, maybe it can help you out?
Source: how to get program files x86 env variable?
EDIT
To be just sure, can you try it with the full path instead of the system variable?
Like this,
#echo off
echo Installing MySQL Server. Please wait...
msiexec /i "mysql-installer-community-5.6.14.0.msi" /qn
echo Configurating MySQL Server...
"C:\Program Files\MySQL\MySQL Server 5.6\bin\mysqlinstanceconfig.exe"
-i -q ServiceName=MySQL RootPassword=mysql ServerType=DEVELOPER
DatabaseType=MYISAM Port=3306 Charset=utf8
echo Installation was successfully
or even
#echo off
echo Installing MySQL Server. Please wait...
msiexec /i "mysql-installer-community-5.6.14.0.msi" /qn
echo Configurating MySQL Server...
cd "C:\Program Files\MySQL\MySQL Server 5.6\bin\" <-- set folder first, then run executeable
mysqlinstanceconfig.exe
-i -q ServiceName=MySQL RootPassword=mysql ServerType=DEVELOPER
DatabaseType=MYISAM Port=3306 Charset=utf8
echo Installation was successfully
My batch file complete:
#echo off
cls
echo ==========================================
echo MySQL Server - Installation - v.17/03/2014
echo ==========================================
echo .
echo .
rem ------------------------------------------------
echo Installing. Wait ...
msiexec /i "mysql-5.5.28-win32.msi" /qn
echo Done.
rem ------------------------------------------------
echo .
echo .
rem ------------------------------------------------
echo Configurating. Waiting ...
cd "C:\Program Files\MySQL\MySQL Server 5.5\bin\"
mysqlinstanceconfig.exe -i -q ServiceName=MySQL RootPassword=mypassword ServerType=DEVELOPER DatabaseType=INODB Port=myport Charset=utf8
echo Done.
rem ------------------------------------------------
echo .
echo .
rem ------------------------------------------------
echo Creating access to user. Waiting ...
cd "C:\Program Files\MySQL\MySQL Server 5.5\bin\"
mysql -uroot -pmypassword --execute="GRANT ALL PRIVILEGES ON . TO 'root'#'%%' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;"
mysql -uroot -pmypassword --execute="FLUSH PRIVILEGES;"
echo Done.
rem ------------------------------------------------
echo .
echo .
echo Installation ready.
echo .
echo .
pause