Contents

Running a MySQL Server instance without installation

Have you ever need to test something in a different version of MySQL Server but you don’t want to make any change on your current environment?, well for this kind of scenarios you could just run a new instance without following the full installation process, in this post you will find a step by step guide to achieve this.


1. Download the MySQL Community Server.

You can Download here the desired version of MySQL Community Server which is totally free!.

Just click in the link pointed in the below image, this will take you to download the latest version available.

MySQL Downloads
MySQL Downloads

Next, you need to download the Zip Archive, from the link in the image, notice the name of the file contains the version and the platform.

MySQL Downloads 2
Zip Archive

Once you have the zip file you can move it to your destination folder and extract all the content there, you can choose any location in your machine, but I recommend to use a path near to the root directory just to don’t deal with large paths later,when you are done you will see a directory structure similar to this:

Folder structure
unzipped

You will see the extracted folder with the same name of the zip file, and inside this folder you will find the internal folders of MySQL.


2. Initialize the Server

To do this, you have to open the command line and go to your extracted folder, then execute the below command :

C:\MySql\mysql-8.0.31-winx64>.\bin\mysqld --initialize

When this execution completes, you will see a new folder named data, inside this folder you need to find a file with the name of your machine, and the extension .err, this file is important because it will contains the temporary generated password for the root user.

if you open the .err file, the last line will be something similar to this:

[Note] [MY-010454] [Server] A temporary password is generated for root@localhost: _+aT.i)aP5Hu

3. Change the administrator password of the MySQL Server

To achieve this, we need first to start the server with the defaults configurations, in the command line execute this command:

C:\MySql\mysql-8.0.31-winx64>.\bin\mysqld --console

then you should see an output similar to this:

 0 [System] [MY-010116] [Server] C:\MySql\mysql-8.0.31-winx64\bin\mysqld.exe (mysqld 8.0.31) starting as process 17528
 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now
 supported for this channel.
 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '::' port: 33060
 0 [System] [MY-010931] [Server] C:\MySql\mysql-8.0.31-winx64\bin\mysqld.exe: ready for connections. Version: '8.0.31'
 socket: ''  port: 3306  MySQL Community Server - GPL.

By default MySQL Server use ports 3306 for regular connections and 33060 for xplugin connections.

To test connection to our server we need to open another command line from the same folder and run below command:

C:\MySql\mysql-8.0.31-winx64>.\bin\mysql -uroot -pYourPasswordHere

Yes, you right, in this command we are saying we want to connect with the user root and we should provide the *password that we got from the .err file.

If you did it correctly, you should see an output similar to this:

mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.31

Copyright (c) 2000, 2022, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

This means we connected succesfully, now we should execute the next command to change the password:

ALTER USER 'root'@'localhost' IDENTIFIED BY 'YOUR_NEW_PASSWORD';

At this point, you should be able to login again with the root user but using your new password.


Extra Notes

  • To shutdown the server you opened with the command line you can press Ctrl + C a few times, this will make that server go down.

  • You can create a .bat file to easy start the server whenever you need, you can use all the options you want add to your server, you can always have a look to the official MySQL Documentation with the available options, also keep in mind the mysql Client Options

  • If you want, you can also use a mysql.ini file to set your desired settings.

  • To find previous versions of the MySQL Server use the Archives link.