How to run mysql server on windows

Running/Starting MySQL without installation on Windows

Normally, I would download MySQL msi installer for windows and install then configure and created the database within the installation steps. Then just connect using whatever application/language and go from there.

However
I want to reach the same result without using the msi installer, instead i want to use the provided MySQL archive. So,

  • I have downloaded (MySQL Community Server => Windows (x86, 64-bit), ZIP Archive mysql-5.7.17-winx64.zip)
  • Extracted the archive.

I want to know how to create and manage a database using those downloaded server files through windows command line.

Most of the search attempts yield results that either assume that msi installation have taken place or are far too complex for someone who is still attempting to learn MySQL basics.

TL;DR : How can i create and manage a database using MySQL server archive files on windows through command line?

3 Answers 3

Thanks to Ryan Vincent’s comment. I was able to follow the steps in MySQL’s reference documentations (For some reason my searches prior to asking this question never found it).

Simplified Steps

Extract the downloaded MySQL Server Archive to the desired location for MySQL server files (example : D:\mysql\mysql-5.7.17-winx64 )

Create a directory for MySQL’s database’s data files (example : D:\mysql\mydb )

Create a directory for MySQL’s database logging (example D:\mysql\logs )

Create MySQL options file (example location : D:\mysql\config.ini )

  • Selected port is 55555
  • [mysqld] groups options relating to mysqld.exe which will be used when mysql.exe reads this configuration file.
  • [mysqladmin] groups options relating to mysqladmin.exe which will be used when mysqladmin.exe reads this configuration file.

Initialize MySQL database files using Windows Batch File/Command Prompt (you might need C++ redistribute if you get an error)

Create a batch file to start the MySQL database server

  • This will read [mysqld] part/group of the configuration file ( D:\mysql\config.ini ) and use options specified there to start the MySQL database server.

Create a batch file to shutdown the MySQL database server

  • This will read [mysqladmin] part/group of the configuration file ( D:\mysql\config.ini ) and use options specified there to specify and shutdown the MySQL database server.

You can now start your database and access it, and shut it down when it is not needed.

DISCLAIMER Those steps are supposed to help you get started with MySQL database and are in no way intended or secure for production.(root user doesn’t even have a password set yet)

Resources And More Details

Chapter 2 Starting the Server for the First Time on Windows

This section gives a general overview of starting the MySQL server. The following sections provide more specific information for starting the MySQL server from the command line or as a Windows service.

Читайте также:  Клонирование диска linux windows

The information here applies primarily if you installed MySQL using the noinstall version, or if you wish to configure and test MySQL manually rather than with the MySQL Installer.

The examples in these sections assume that MySQL is installed under the default location of C:\Program Files\MySQL\MySQL Server 8.0 . Adjust the path names shown in the examples if you have MySQL installed in a different location.

Clients have two options. They can use TCP/IP, or they can use a named pipe if the server supports named-pipe connections.

MySQL for Windows also supports shared-memory connections if the server is started with the shared_memory system variable enabled. Clients can connect through shared memory by using the —protocol=MEMORY option.

For information about which server binary to run, see Selecting a MySQL Server Type.

Testing is best done from a command prompt in a console window (or “ DOS window ” ). In this way you can have the server display status messages in the window where they are easy to see. If something is wrong with your configuration, these messages make it easier for you to identify and fix any problems.

The database must be initialized before MySQL can be started. For additional information about the initialization process, see Initializing the Data Directory.

To start the server, enter this command:

For a server that includes InnoDB support, you should see the messages similar to those following as it starts (the path names and sizes may differ):

When the server finishes its startup sequence, you should see something like this, which indicates that the server is ready to service client connections:

The server continues to write to the console any further diagnostic output it produces. You can open a new console window in which to run client programs.

If you omit the —console option, the server writes diagnostic output to the error log in the data directory ( C:\Program Files\MySQL\MySQL Server 8.0\data by default). The error log is the file with the .err extension, and may be set using the —log-error option.

The initial root account in the MySQL grant tables has no password. After starting the server, you should set up a password for it using the instructions in Securing the Initial MySQL Account.

How do I start a MySQL server on Windows?

I’ve installed a MySQL server onto my computer and when I first installed it, it ran automatically. Now I’ve restarted my computer it is no longer running. What file do I need to run to get it back up and running again?

Читайте также:  Как открыть текстовый файл от имени администратора windows 10

I’ve tried running MySQL 5.6 Command Line Client and mysqld.exe from the Program Files/MySQL/MySQLServer/bin directory, and I’ve had no luck.

Upon running mysqld.exe, I get the following error:

Naturally, I tried running it as administrator, and I got this:

5 Answers 5

Make sure the mysqld.exe is ticked under the Startup tab when you go to run and type msconfig . Also, same goes for Services , look for the MySQL services there, right click > properties and make sure the startup types are selected as automatic.

If you installed MySQL using the MSI installer, it should be set up as a service.

You can open the service in two ways

METHOD #1: Access the Installed Service

  • Open up the Services icon in the Control Panel
  • Scroll alphabetically to the MySQL service
  • Right click the service
  • Click Start Service

METHOD #2: Command Line Execution

  • Open DOS Window
  • From the C: Prompt, run this: net start mysql or ‘net start mysql57’. The right name may vary on your system

If you get this error

then you didn’t run the DOS Window as Administrator. Try again as administrator. You should see:

Give it a try.

I had the similar issue and found later that the encoding of my.ini file changes if you open that from notepad. Open the file from Notepad++ and make sure to take a note of the .ini file encoding (mostly it is UTF-8). If the file encoding changes SQL service will not start. Make sure that the new directory in which the data path is set has permissions for the account that runs the mySQLd service in windows (mostly it is network service).

If you are using wamp on windows, you can start mysql from command line by :

This assumes that you have installed wamp at the root

In order to start manually the mysql serve you must run the mysqld executable. Open the command prompt and type:

If mysqld doesn’t start, check the error log. The error log is located in the C:\Program Files\MySQL\MySQLServer\data. It is the file with a suffix of .err. You can also try to start the server as mysqld —console; in this case, you may get some useful information on the screen that may help solve the problem.

How to run mysql server on windows

The MySQL server can be started manually from the command line. This can be done on any version of Windows.

To start the mysqld server from the command line, you should start a console window (or “ DOS window ” ) and enter this command:

The path to mysqld may vary depending on the install location of MySQL on your system.

Читайте также:  Что такое linux open suse

You can stop the MySQL server by executing this command:

If the MySQL root user account has a password, you need to invoke mysqladmin with the -p option and supply the password when prompted.

This command invokes the MySQL administrative utility mysqladmin to connect to the server and tell it to shut down. The command connects as the MySQL root user, which is the default administrative account in the MySQL grant system.

Users in the MySQL grant system are wholly independent from any operating system users under Microsoft Windows.

If mysqld doesn’t start, check the error log to see whether the server wrote any messages there to indicate the cause of the problem. By default, the error log is located in the C:\Program Files\MySQL\MySQL Server 8.0\data directory. It is the file with a suffix of .err , or may be specified by passing in the —log-error option. Alternatively, you can try to start the server with the —console option; in this case, the server may display some useful information on the screen to help solve the problem.

How to start MySQL server on windows xp

Whenever I try to start MySQL by typing

I get the error

ERROR 2003(HY000): Can’t connect to MySQL server on ‘localhost’ (10061)

How can I solve the problem above? I just downloaded MySQL and unzipped it in the E: drive. I have not done anything else. Do I have to make a connection first? If so, how can I do that?

19 Answers 19

The MySQL server can be started manually from the command line. This can be done on any version of Windows.

To start the mysqld server from the command line, you should start a console window (or “DOS window”) and enter this command:

You can stop the MySQL server by executing this command:

If the MySQL root user account has a password, you need to invoke mysqladmin with the -p option and supply the password when prompted.

This command invokes the MySQL administrative utility mysqladmin to connect to the server and tell it to shut down. The command connects as the MySQL root user, which is the default administrative account in the MySQL grant system. Note that users in the MySQL grant system are wholly independent from any login users under Windows.

If mysqld doesn’t start, check the error log to see whether the server wrote any messages there to indicate the cause of the problem. The error log is located in the C:\Program Files\MySQL\MySQL Server 5.0\data directory. It is the file with a suffix of .err. You can also try to start the server as mysqld —console; in this case, you may get some useful information on the screen that may help solve the problem.

Оцените статью