The most detailed tutorial on how to connect eclipse to mysql on the whole network

Step 1: Let's do the environmental preparations before the connection

1. First download the driver on the MySQL official website: (The download address blogger has sorted it out for everyone and uses it directly)

https://dev.mysql.com/downloads/file/?id=498587

down like this

 2. Create a new project in eclipse

 

3. Add the driver to eclipse

Step 3: Select the jar file you just installed 

Step Four: Success Stories 

 Step 5: Create a new class for testing

 

Click Finish

If successful, it will display:

 

 I have written the specific code and can use it directly (the uploaded resources are self-collected for free)

 Finished product:

pass: You will report an error when you copy it. The reason for the error is that the class is not exported

Solution: Click ctrl+shift+o to select the third

 

 third step:

Open cmd and run as administrator:

 Enter net start mysql to start the service. Here everyone’s service name is not uniform. Some people changed it later, but basically it is either mysql or mysql57. You can use services.msc to press Enter to check the specific name of the mysql service and start it again. If u root -p cannot be executed, it means that the environment variable is not configured properly. You can edit the environment variable and click the environment variable by yourself.

 

 

Environment variable method one:

 Click path:

Paste the above address of your mysql installation bin and click OK 

 

 Method 2: Enter in the administrator cmd

MySQL Server Instance Config Wizard

In this way, it is more convenient to automatically configure environment variables locally (recommended)

Step 4: After the configuration is complete, you can use mysql -u root -p to enter the root user password and enter the mysql page

After that, you can execute mysql operations in cmd

 

 Here I use the st database and the stu data table to give you a demonstration

 Step 5: Go back to eclipse and follow the steps to start the code

 Result: Finally, the data on mysql can be displayed on eclipse, and eclipse is also correctly connected to mysql at this time

 

 The blogger here also uploads the eclipse installation package to the appendix for everyone to use for free. I wish you a happy experiment. If there is anything you don’t know, leave a message below, and I will reply when I see it

Guess you like

Origin blog.csdn.net/m0_68976043/article/details/130939872