Home  >  Article  >  Database  >  How to install mysql after downloading it

How to install mysql after downloading it

下次还敢
下次还敢Original
2024-04-05 18:06:191081browse

MySQL installation steps: Download the installation package. Install MySQL based on package type. Initialize the database. Configure MySQL settings. Take safety measures.

How to install mysql after downloading it

MySQL Installation Guide

Installing MySQL involves the following steps:

First Step: Download the installation package

Visit the MySQL official website to download the installation package suitable for your operating system.

Step 2: Install MySQL

According to the type of installation package you downloaded, perform the following steps:

  • .msi installation package (Windows):

    • Double-click the installation package.
    • Follow the installation wizard.
    • Enter the password to set up the MySQL root account.
  • .tar.gz Installation package (Linux):

    • Extract the installation package to the target directory.
    • Use the following command to start the MySQL service:

      <code>sudo /path/to/mysql/bin/mysqld_safe --user=mysql</code>

##Step 3: Initialize the database

After starting MySQL for the first time, you need to initialize the database:

  • Use the following command to log in to MySQL:

    <code>mysql -u root -p</code>
    (Enter the root password you set during the installation process)

  • Run the following command to initialize the database:

    <code>CREATE DATABASE mysql CHARACTER SET utf8 COLLATE utf8_general_ci;
    GRANT ALL PRIVILEGES ON mysql.* TO 'root'@'localhost' IDENTIFIED BY 'your_password';
    FLUSH PRIVILEGES;</code>

Step 4: Configure MySQL

According to your You can configure various settings of MySQL according to your needs. For example, you can modify the configuration file

my.cnf to adjust memory usage or logging levels.

Step 5: Security Settings

To ensure MySQL security, it is recommended to take the following steps:

    Enable strong passwords.
  • Restrict remote access to MySQL.
  • Create database backups regularly.

At this point, you have successfully installed and configured MySQL.

The above is the detailed content of How to install mysql after downloading it. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn