How to set up mysql in this computer to allow other people's computers to connect

To allow someone else's computer to connect to the MySQL database on your computer, the following steps are required:

1. Confirm that the MySQL service has been started: In the Windows system, you can check whether the MySQL service has been started in the service manager.

2. Modify the MySQL configuration file: Open the MySQL configuration file my.ini (or my.cnf), find the [mysqld] section, and add the following content in it: ``` bind-address=0.0.0.0 ``` This allows Any IP address to connect to the MySQL server.

3. Create a MySQL user and authorize: Create a new user in MySQL and authorize it to access the database. The following commands can be used:

```

CREATE USER 'username'@'%' IDENTIFIED BY 'password';

GRANT ALL PRIVILEGES ON *.* TO 'username'@'%';

FLUSH PRIVILEGES;

```

Where 'username' is the username you want to create, and 'password' is the user's password. % indicates that any IP address is allowed to connect to the MySQL server.

4. Open the MySQL port: Open the MySQL port (3306 by default) in the firewall to allow external connections.

After completing the above steps, others can use the MySQL client to connect to your MySQL server. Connecting requires your computer's IP address as the server address, and the username and password you created.

Guess you like

Origin blog.csdn.net/m0_52191385/article/details/130076722