Home  >  Article  >  Database  >  mysql installation tutorial

mysql installation tutorial

下次还敢
下次还敢Original
2024-04-22 18:00:271280browse

The steps required to install MySQL are as follows: Download the installer and install it. Initialize MySQL and set a temporary root password. Set a secure root password. Configure MySQL to allow remote connections and adjust the maximum number of connections. Restart MySQL to apply configuration changes. Connect to MySQL using the root password.

mysql installation tutorial

MySQL installation tutorial

Step 1: Download MySQL

Download the MySQL installer for your operating system from the official MySQL website.

Step 2: Install MySQL

  • Windows:Run the installer and follow the prompts to install, making sure to select "Custom" installation , and select "MySQL Server" and "MySQL Workbench".
  • macOS: Install using Homebrew: brew install mysql.
  • Linux: Install using a package manager, for example:

    • Ubuntu/Debian: sudo apt-get install mysql-server
    • CentOS/Red Hat: sudo yum install mysql-server

##Step 3: Initialize MySQL

After the installation is complete, initialize MySQL using the following command:

<code>mysqld --initialize-insecure</code>
This will create the initial database and set a temporary root password.

Step 4: Set root password

Connect to MySQL and set a secure root password:

<code>mysql -u root -p
ALTER USER 'root'@'localhost' IDENTIFIED BY '<new_password>';</code>

Step 5: Configure MySQL

Edit the configuration file

my.cnf or my.ini (the exact location depends on the operating system):

    Settings
  • bind-address is 0.0.0.0 to allow remote connections.
  • Set
  • max_connections to a reasonable value to adjust the maximum number of connections.

Step 6: Restart MySQL

Restart MySQL to apply configuration changes:

<code>service mysql restart</code>

Step 7: Connect to MySQL

Connect to MySQL using your root password:

<code>mysql -u root -p</code>

Congratulations! You have successfully installed and configured MySQL.

The above is the detailed content of mysql installation tutorial. 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