How To Install and use MySQL | Part – I

How To Install and use MySQL | Part – I

13 June 2023 1 By Harshvardhan Mishra

Almost all web applications require server-based data storage, and MySQL continues to be the most-used database solution. In This Tutorial-Aarticle, I am going to install MySQL in Windows machine and discuss various options for using MySQL.

We know that MySQL is a free, open-source relational database. A famous MariaDB is a fork of the database created in 2010 following concerns about the Oracle acquisition of MySQL. (It’s is functionally identical, so most of the concepts described in this article also apply to MariaDB.)

While NoSQL databases have surged in recent years, relational data is generally more practical for the majority of applications/projects. That said, MySQL also supports NoSQL-like data structures such as JSON fields so you can enjoy the benefits of both SQL and No-SQL. This can be very useful for your Web Development Projects.

Let’s discuss How to use MySQL in your local development environment.

We have mainly three way to use MySQL in your local development environment:

  • Installing on your PC.
  • Cloud-based solutions
  • Using Docker containers

We discuss only first way “Installing on your PC” in this article. If you want to use a single instance of MySQL across numerous projects or need the service to start automatically, installing MySQL on your local development workstation can be a sensible option.

Method 1 – All-in-one Packages

Nowadays many excellent All-in-one packages are avialable for all-in-one macOS, Linux, and Windows distributions which contain Apache, PHP, MySQL, phpAdmin, SSL certificates, frameworks, and other applications in a single installation package.

Here a list of some excellent popular all-in-one packages:

Most all-in-one packages are ideal for quick PHP and MySQL development set-ups and may offer multiple editions of each service.

But there are some problems with these all-in-one packages:

  • Updates are not guaranteed. Many packages still offer older editions of MySQL.
  • Developers using different OSes or tweaking configurations can introduce compatibility issues in shared codebases.
  • Development and production environments can be significantly different.

After this discussion, W e can say that All-in-one packages are best for projects with a single programmer or those who are new to web development on for business oriented web applications.

Method 2. Install MySQL on PC manually


Linux is open-source and we have lot of Linux distributions. A famous one is UBUNTU. Lot of Online web Hosting provider using CENTOS. So Linux is widely used by users for developing and running web applications.

There are numerous ways to install MySQL on a variety of Linux distros:

  • Some distros such as Ubuntu Server provide MySQL by default.
  • The official documentation provides details for installation using APT, Yum, and SLES package managers as well as RPM and Debian packages.
  • Different versions of MySQL are available from the snap store.

Example install via APT

  • Update the system package repository to ensure you are installing the latest MySQL release.
  • Open the terminal and run the following command:  sudo apt update
  • Enter your password and wait for the update to finish.
  • Next, run: sudo apt upgrade
  • Enter Y when prompted to continue with the upgrade and hit ENTER. Wait for the upgrade to finish.
  • After successfully updating the package repository, install MySQL Server by running the following command:
  • sudo apt install mysql-server
  • When asked if you want to continue with the installation, answer Y and hit ENTER.

Note: If you only want to connect to a remote MySQL server instead of hosting a database on your machine, install only the MySQL Client by running: sudo apt install mysql-client

  • Check if MySQL was successfully installed by running: mysql --version

Securing MySQL

Secure your MySQL user account with password authentication by running the included security script:sudo mysql_secure_installation

Enter your password and answer Y when asked if you want to continue setting up the VALIDATE PASSWORD component. The component checks to see if the new password is strong enough.

Enter 0, 1, or 2 depending on the password strength you want to set. The script then instructs you to enter your password and re-enter it afterward to confirm.

Any subsequent MySQL user passwords need to match your selected password strength.

Note: Even though you are setting a password for the root user, this user does not require password authentication when logging in.

The program estimates the strength of your password and requires confirmation to continue.

Press Y if you are happy with the password or any other key if you want a different one.

The script then prompts for the following security features:

  • Remove anonymous users?
  • Disallow root login remotely?
  • Remove test database and access to it?
  • Reload privilege tables now?

The recommended answer to all these questions is Y. However, if you want a different setting for any reason, enter any other key.

For example, if you need the remote login option for your server, enter any key other than Y for that prompt.

Check if MySQL Service Status

After successfully installing MySQL, the MySQL service starts automatically. sudo systemctl status mysql

Log in to MySQL Server

Run the following command: sudo mysql -u root

Now you can execute queries, create databases, and test out your new MySQL setup

Install MySQL on macOS

Download the native package installer .dmg disk image. Double-click to mount the image then double-click the .pkg file to start the installation wizard.

Alternative way

Install MySQL on Windows

Download installer and install it. link is

Suggested Readings!