解决:mybatis-generator-maven-plugin:1.3.2:generateAccess denied for user 'root'@'localhost'

问题描述
Failed to execute goal org.mybatis.generator:mybatis-generator-maven-plugin:1.3.7:generate (default-cli) on project springboot_v2: Access denied for user ‘root’@‘localhost’ (using password: YES)

Failed to execute goal org.mybatis.generator:mybatis-generator-maven-plugin:1.3.7:generate (default-cli) on project springboot_v2: Access denied for user 'root'@'localhost' (using password: YES)

可能原因

1、root用户没有权限访问该数据库并进行表的增删改查操作

解决方案

修改root用户在该数据库的权限,即添加相应权限
在navicat中新建查询执行以下代码

GRANT Alter, Alter Routine, Create, Create Routine, Create Temporary Tables, Create View, Delete, Drop, Event, Execute, Grant Option, Index, Insert, Lock Tables, References, Select, Show View, Trigger ON `springbootv2`.* TO `root`@`localhost`;

springbootv2是数据库的名字,这里需要填你自己的数据库。
图形化界面如对相应数据库添加用户权限即可。
解决:mybatis-generator-maven-plugin:1.3.2:generateAccess denied for user 'root'@'localhost'_第1张图片

2、pom文件中,mybatis.generator插件的配置文件目录错误。

解决方案

generator.xml文件的位置正确填写在pom文件中

示例
配置文件路径
解决:mybatis-generator-maven-plugin:1.3.2:generateAccess denied for user 'root'@'localhost'_第2张图片

		
			<plugin>
				<groupId>org.mybatis.generatorgroupId>
				<artifactId>mybatis-generator-maven-pluginartifactId>
				<version>1.3.7version>
				<configuration>
					
					<verbose>falseverbose>
					
					<overwrite>falseoverwrite>
					
					<configurationFile>src/main/resources/generator/MyBatisGenerator/generator.xmlconfigurationFile>
				configuration>
				<dependencies>
					<dependency>
						<groupId>mysqlgroupId>
						<artifactId>mysql-connector-javaartifactId>
						<version>${mysql.version}version>
					dependency>
				dependencies>
			plugin>

你可能感兴趣的:(疑惑)