springboot连接mysql问题解决

学习的项目路径:https://www.bysocket.com/?p=1627
即:https://github.com/JeffLi1993/springboot-learning-example 下面的springboot-restfull

准备工作:下载了Postman工具做http请求接口验证。使用2018-idea IDE。
工程放在了自己的MAC本上。

1. mac上新安装了8.0.13的mysql
   工程项目是使用的mysql-connector-java:5.1.39
   直接修改成8.0.13之后会报错,再接着修改其它的依赖,也不行,无奈,项目中依赖的包太多。
   
 => 准备使用自己台式机的上mysql,台式机上的是5.5.47版本,应该可以。
 2. 在工程中配置使用自己的台式机的mysql。
    依然连接不上。
    报错:Could not get JDBC Connection; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server. Attempted reconnect 3 times. Giving up.

=> 按照朋友的推荐下载了一个mysqlworkbench。MAC mysql可以连接,但是台式机上的mysql连接不上。
    中间报错can't connect to mysql server***(61)
    最后的解决方法是:
    a. 创建了一个mysql账户,使其有在所有IP上的连接的权限。
    CREATE USER '

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
使用Spring Boot连接MySQL数据库时,可以使用JDBC进行连接。首先,需要在项目的pom.xml文件中添加相应的依赖项。可以通过添加以下代码来引入相关依赖项: ```xml <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <scope>runtime</scope> </dependency> ``` 其中,`spring-boot-starter-web`是Spring的Web开发框架,`mysql-connector-java`是MySQL连接器。请确保版本与您使用的Spring Boot和MySQL版本兼容。 接下来,您需要在Spring Boot应用程序的配置文件(通常是application.properties或application.yml)中配置MySQL数据库连接信息,包括URL、用户名和密码。例如: ```properties spring.datasource.url=jdbc:mysql://localhost:3306/mydatabase spring.datasource.username=your-username spring.datasource.password=your-password ``` 请将`your-username`和`your-password`替换为您的MySQL数据库的实际用户名和密码,并根据需要修改数据库URL。 最后,您可以在Spring Boot应用程序中使用JDBC来访问和操作MySQL数据库。您可以编写相应的代码来执行SQL查询、插入、更新或删除操作。可以使用Spring的JdbcTemplate或MyBatis等库来简化数据库访问的操作。 希望这些信息对您有所帮助!<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [Java SpringBoot 使用JDBC连接Mysql数据库(整套解决方案带源码和安装包)](https://blog.csdn.net/Highning0007/article/details/123811891)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] - *2* *3* [SpringBoot 连接 MySQL](https://blog.csdn.net/weixin_42555971/article/details/127427845)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值