How to Run MySQL Without Installation in Windows (Portable MySQL)
Nowadays most of the developers use more that one server’s in a machine, and they are installing different servers by changing the default port of that particular server. and all servers are running parallelly in the machine when a machine starts. that consumes more memory and it uses huge resource even they are not using it.
Some expert developers stop the services at startup time and free the resources. In case of MySQL server we can do the same process but when we want to change the machine we have to take backup of database and all other associated process(Import, Export, etc.).
But in the case of MySQL, we can use Run MySQL Without Installation in Windows (Portable MySQL). If you want to change your machine you can simply copy your portable MySQL from one machine to another machine.
Steps to Run MySQL Without Installation in Windows
1. Download the MySQL Zip archive:
Download the MySQL Zip archive from the official website: Click Here.
2. Extract the Zip File:
After download extract the ZIP file in your preferred Location
3. Create Data Folder:
In the earlier version of MySQL data folder is already present that contains the data files. (Create a folder “data” in current directory)
4. Create Configuration File:
Also, copy “my-default.ini” file and rename it my.ini, but keep both “my-default.ini” and “my.ini” files in current directory.(You can also create my.ini file your own but you have to copy and paste all data of “my-default.ini” file in “my.ini” file)
5. Edit Configuration File “my.ini”:
Open “my.ini” file and under [mysql] section, add the following parameters.
basedir = "/mysql-5.7.17"
datadir = "/mysql-5.7.17/data"
tmpdir = "/mysql-5.7.17/tmp"
port = 3306
server_id = 1
log_error = "mysql_error.log"
pid_file = "mysql.pid"
socket = "/mysql-5.7.17/mysql.sock"
# Optional – Default Configuration
max_allowed_packet = 8M
# Where do all the plugins live
plugin_dir = “/mysql-5.7.17/lib/plugin/”
after editing “my.ini” file it looks like:
The Optional – Default Configuration section is optional, you can remove or change it as needed. Reference to the configurations can be found on the official page: Click Here
6. Initialization MySQL (It needs only once)
This process will create necessary files and databases that used to run MySQL including making a username and optionally a password and set privileges to the user.
The Difference is: mysqld –initialize will create a random password that written to the log file, in this example mysql_log.log file located in the data folder.
While for mysqld –initialize-insecure, there is no password to be set, Nevertheless, we can still create a password later.
By default, the process will create a user to login with root as the username, we can define another username by adding –user option, e.g. mysqld –initialize-insecure –user=admin_user
For simplicity, in this example, we will initialize using the default username ( root ) without a password. Open a command prompt and navigate the cursor to the bin folder, then, run the command mysqld –initialize-insecure
Wait for a while until the process complete, if successful, the data folder will contain files and folders as shown in the following figure:
7. Start MySQL Server:
In Current Directory go inside the bin folder and double click on “mysqld.exe”
Note: After Clicking on mysqld.exe, if everything is fine then it will close automatically other wise it will shows errors in console.
8.Use MySQL Server:
9. ShutDown MySQL Server:
After using it you can Shutdown the MySQL server using command “mysqladmin -u root shutdown”