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

How to configure mysql after downloading it

下次还敢
下次还敢Original
2024-04-05 16:54:23527browse

In order to configure the downloaded MySQL, you need to complete the following steps: download MySQL and install it; initialize MySQL; modify the configuration file (change the root password, set connection parameters); create the mysqld service; start MySQL; connect through the MySQL shell Go to MySQL; create database and user.

How to configure mysql after downloading it

MySQL configuration guide after downloading

1. Download MySQL

Visit the MySQL official website https://www.mysql.com/downloads/ to download the MySQL version suitable for your operating system.

2. Install MySQL

Follow the instructions in the installation wizard to install. Make sure to select the "Custom" installation option so you can choose the installation path and configuration options.

3. Initialize MySQL

After the installation is complete, open a command prompt or terminal window and run the following command:

<code>mysql_install_db --user=mysql --basedir=/path/to/mysql --datadir=/path/to/data</code>

4 . Configure MySQL

  • Modify the configuration file

Open the MySQL configuration filemy.cnf (usually located at /etc/mysql/my.cnf or /usr/local/mysql/etc/my.cnf), make the following modifications as needed:

  • Change root password: Find the [mysql] section and add password=new_password.
  • Set connection parameters: Adjust settings such as bind-address, port, and max_connections to suit your specific need.
  • Create the mysqld service

On a Linux system, run the following command to create the mysqld service:

<code>sudo systemctl enable mysqld</code>

On Windows systems, run the following command to create the mysqld service:

<code>net start mysql</code>

5. Start MySQL

Use the following command to start MySQL:

<code>sudo systemctl start mysqld</code>

6. Connect to MySQL

Use the following command to connect to MySQL through the MySQL shell:

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

Enter the root password you set in step 4.

7. Create a database and user

Create a database and user:

<code>CREATE DATABASE database_name;
CREATE USER 'username' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON database_name.* TO 'username';</code>

Now, you have successfully configured MySQL.

The above is the detailed content of How to configure 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