Page Content

Tutorials

How to Install MySQL on Microsoft Windows?

Install MySQL

MySQL installation entails downloading the program, launching an installer, or following operating system-specific instructions. You may get installation instructions for MySQL on dev.mysql.com. The MySQL Community Server and other MySQL downloads can usually be found at dev.mysql.com/downloads or other comparable websites. Depending on your operating system and preferred version, you should select the relevant download link. Linux, Microsoft Windows, and Mac OS are just a few of the hardware and operating systems on which MySQL may be installed and used.

Using the MySQL Installer is frequently the suggested method for Windows. Usually, you double-click the installation file to launch the MySQL Setup Wizard after downloading it. You can select the “Typical” setup type and optional components, as well as the installation path, using the wizard. You typically go ahead and setup the new server after copying the installation files.

Depending on the distribution, different Linux installation techniques are used. Typically, package managers such as Yum or APT are used, or RPM packages or generic binaries downloaded from Oracle are installed. To install particular MySQL packages, such as the server, client, and development files, older techniques refer to using the rpm command. Initializing the data directory is required following the installation of generic binaries.

Using the macOS installer package is the suggested method for macOS.

Recommended Installation Bundles

MySQL can be installed alone, however several recommend packing it with Apache and PHP. XAMPP, WAMP, MAMP, and AMPPS are recommended installers. One quick installation includes Apache, MySQL, PHP, and Perl with XAMPP. These bundles are recommended for setting up a PC web server.

Use of specialized MySQL management tools is an alternative. A free MySQL management tool, MySQL Workbench offers a comprehensive setting for database design, SQL development, and administration. In addition to command-line SQL, it provides a graphical user interface (GUI) for tasks. Another popular web-based frontend (graphical interface) for MySQL that is frequently included with XAMPP is called phpMyAdmin. It enables users to write queries in a SQL box or interact with MySQL using mouse clicks.

Basic Configuration Steps

Usually, you have to setup the MySQL server after the installation files are in place. You’ll probably be prompted to input and remember a root user password during the configuration process, particularly if you’re utilizing installers like the MySQL Setup Wizard for Windows. You will need to enter this password each time you launch MySQL or log in as the root user.

A temporary root password may be created and shown in the standard error stream or saved in the error log file for certain Linux installs that use generic binaries and data directory initialization. You should change your root password right away if you are logging in with a temporary one.

Since MySQL sometimes comes with a blank password for the root account by default, it is strongly advised that you specify a password for this user. The mysqladmin tool can be used from the command line to modify the root password.

Here are some instances of how to modify the root password using the command line:

  • Using mysqladmin: mysqladmin -u root password “new_password”;
  • Using ALTER USER (MySQL 5.7.6 and newer) or SET PASSWORD (older versions) after connecting as root. This often requires stopping the server, restarting it with –skip-grant-tables, connecting, changing the password, flushing privileges, and then restarting the server normally.

Example with ALTER USER (updated versions) following skip-grant-tables connection to the MySQL prompt:

FLUSH PRIVILEGES; 
ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password'; 
FLUSH PRIVILEGES; 
exit; 

Since the root account is mostly used for administration, it’s crucial to create additional user accounts with restricted permissions for general operations after setting the root password. SQL procedures like CREATE USER and GRANT or graphical user interfaces like phpMyAdmin can be used for this.

Starting and Stopping the MySQL Database Softwar

The MySQL server must be started after installation and configuration in order to communicate with databases. Your operating system and the way MySQL was installed will determine how to start and stop it.

MySQL can usually be started and stopped using the XAMPP control panel if you installed a bundle like XAMPP. In a similar manner, this control panel allows you to stop or configure MySQL.

Using Linux’s command line, you can use ps -ef | grep mysqld to see if the server is running,./safe_mysqld & or bin/mysqld_safe –user=mysql & to start it, and./mysqladmin -u root -p shutdown or bin/mysqladmin -u root shutdown to end it. Your Windows computer may have MySQL.Start the command-line client as a Windows service or within the installation directory with EXE.

After launching the server, use the mysql command-line client with a username and password to connect.

An example of using the command line to connect as root:

mysql -u root -p

The root password will then need to be entered.

Type QUIT or EXIT to close the MySQL command prompt.

Index