Install MySQL

Install MySQL

How to Install MySQL

Installing MySQL involves downloading the MySQL server package and setting it up on your system. Follow the instructions below for your operating system.


1. Installing MySQL on Windows

Step 1: Download MySQL Installer

  1. Visit the MySQL Downloads page.
  2. Download the MySQL Installer for Windows (Community Edition).

Step 2: Run the Installer

  1. Double-click the downloaded .msi file to launch the installer.
  2. Choose Setup Type:
    • Developer Default: Installs all MySQL products.
    • Server Only: Installs only the MySQL Server.
    • Custom: Allows you to select specific components.

Step 3: Configure MySQL Server

  1. Choose the version of MySQL Server to install.
  2. Configure the server:
    • Type and Networking: Select the server type (Standalone or InnoDB Cluster) and port (default is 3306).
    • Authentication: Set the root password and add additional users if needed.
    • Windows Service: Configure MySQL to run as a Windows service.

Step 4: Complete the Installation

  1. Finish the configuration and start the MySQL server.
  2. Open the MySQL Command Line Client or MySQL Workbench to connect and manage the server.

2. Installing MySQL on macOS

Step 1: Download MySQL

  1. Visit the MySQL Downloads page.
  2. Download the DMG Archive for macOS.

Step 2: Install MySQL

  1. Open the downloaded .dmg file and double-click the installer package.
  2. Follow the installation steps:
    • Accept the license agreement.
    • Choose the installation location.
  3. Set a root password during the installation.

Step 3: Start MySQL

  1. After installation, MySQL is installed as a macOS System Preference.
  2. Open System Preferences, click MySQL and click Start to run the server.

Step 4: Verify the Installation

  1. Open the terminal and run:
    mysql -u root -p
  2. Enter the root password to access the MySQL shell.

3. Installing MySQL on Linux

Step 1: Update the Package Index

sudo apt update # For Debian/Ubuntu sudo yum update # For CentOS/RedHat

Step 2: Install MySQL

  • On Debian/Ubuntu:
    sudo apt install mysql-server
  • On CentOS/RedHat:
    sudo yum install mysql-server

Step 3: Start and Enable MySQL

sudo systemctl start mysqld sudo systemctl enable mysqld

Step 4: Secure MySQL Installation

Run the security script to remove test data and set the root password:

sudo mysql_secure_installation

Step 5: Access MySQL

  1. Log in to the MySQL shell:
    mysql -u root -p
  2. Enter the root password to access the MySQL prompt.

4. Verify MySQL Installation

  1. Check the MySQL version:
    mysql --version
  2. Connect to the MySQL server:
    mysql -u root -p
  3. Create a test database to ensure functionality:
    CREATE DATABASE test_db; SHOW DATABASES;

5. MySQL Workbench (Optional)

To manage MySQL with a GUI, download and install MySQL Workbench from the official downloads page. It allows you to interact with MySQL databases visually.

6. Troubleshooting

  • Port 3306 Blocked: Ensure the port is not blocked by a firewall.
  • Service Fails to Start: Check the logs for errors, typically located in /var/log/mysql/ (Linux) or in the MySQL installation folder.
  • Forgot Root Password: Reset the root password using the --skip-grant-tables option.

Let me know if you'd like detailed steps for any specific operating system!

Soeng Souy

Soeng Souy

Website that learns and reads, PHP, Framework Laravel, How to and download Admin template sample source code free.

Post a Comment

CAN FEEDBACK
close