MySQL is a cross-platform database that can be also run and used in Windows operating systems. We can use the Windows MySQL command line server and client via the command line interfaces like MS-DOS or PowerShell. In this tutorial, we examine how to run MySQL via the command line interface in Windows.
Run MySQL Database Server From Command Line
The MySQL database server is installed in the
C:\Program Files\MySQL folder in Windows operating systems. If you use 64-bit Windows but the MySQL database server is 32-bit the installation path is
C:\Program Files(x86)\MySQL . MySQL can be installed multiple times with different versions in Windows and every installation has the following path. For example, if the MySQL database version 8 is installed the path is like below.
C:\Program Files\MySQL\MySQL Server 8.0\
If the MySQL database server version is 7 installation path is like the one below.
C:\Program Files\MySQL\MySQL Server 7.0\
The MySQL server binary is located in the
bin directory of the installation with the name of
mysqld . We can start the MySQL server via command line by running this daemon like below.
> "C:\Program Files\MySQL\MySQL Server 8.0\bin\mysqld"
Run MySQL Client From Command Line
MySQL client is used to connect MySQL database servers. MySQL client can be used to create, delete, update databases, tables, users and data. We can run SQL and MySQL commands for these actions. First we should connect to the MySQL database server by using the MySQL client. Similar to the MySQL Database Server binary the MySQL client binary is located under the MySQL installation folder
bin directory. For MySQL 8 it is located like below.
C:\Program Files\MySQL\MySQL Server 8.0\bin\mysql
We can simply call the
mysql command like below by providing the connection parameters like MySQL database server IP address/host , username, and password. Password is generally provided interactively for security reasons during connection. In the following example, we connect to the MySQL database server in 192.168.1.10 by using the user name
root . The following command can be executed in MS-DOS (Command Prompt) or PowerShell.
> "C:\Program Files\MySQL\MySQL Server 8.0\bin\mysqld -uroot -p 192.168.1.10