MySQL用户权限导致的创建Trigger失败_MySQL
说来惭愧,MySQL一直处于只会用,不怎么理解的阶段。甚至是一些较为深层次的管理,都不怎么熟悉,得加强啊!
近日,系统测试,使用MySQL数据库,需要在某个表上创建触发器,数据库是在本机安装。但是,无论如何都无法创建触发器,后台错误信息如下:
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: TRIGGER command denied to user 'root'@'mortimer-PC' for table 't_user' at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:513) at com.mysql.jdbc.Util.handleNewInstance(Util.java:411) at com.mysql.jdbc.Util.getInstance(Util.java:386) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1052) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4096) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4028) at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2490) at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2651) at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2677) at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2627) at com.mysql.jdbc.StatementImpl.execute(StatementImpl.java:841) at com.mysql.jdbc.StatementImpl.execute(StatementImpl.java:681) at com.apusic.jdbc.adapter.StatementHandle.execute(Unknown Source) at com.apusic.esb.base.util.SQLUtil.createDBObjectIfNecessary(SQLUtil.java:263) at com.apusic.esb.base.util.SQLUtil.createDBObjectIfNecessary(SQLUtil.java:225) at com.apusic.esb.config.trigger.mysql.MySqlTriggerManager.createTriggersIfNecessary(MySqlTriggerManager.java:83) at com.apusic.esb.config.trigger.TriggerConfigManager.deploy(TriggerConfigManager.java:331) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at com.apusic.esb.base.communication.CommInvokeUtil.invoke(CommInvokeUtil.java:139) at com.apusic.esb.base.communication.CommInvokeUtil.invoke(CommInvokeUtil.java:43) at com.apusic.esb.base.communication.CommInvokeUtil.invoke(CommInvokeUtil.java:27) at com.apusic.esb.base.communication.socket.server.CommSocketServer$RequestProcessor.run(CommSocketServer.java:99) at com.apusic.util.ThreadPoolImpl$WorkerThread.run(Unknown Source)2014-06-25 10:38:42 错误 [apusic.com.apusic.esb.config.trigger.TriggerConfigManager] com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: TRIGGER command denied to user 'root'@'mortimer-PC' for table 't_user' at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:513) at com.mysql.jdbc.Util.handleNewInstance(Util.java:411) at com.mysql.jdbc.Util.getInstance(Util.java:386) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1052) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4096) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4028) at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2490) at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2651) at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2677) at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2627) at com.mysql.jdbc.StatementImpl.execute(StatementImpl.java:841) at com.mysql.jdbc.StatementImpl.execute(StatementImpl.java:681) at com.apusic.jdbc.adapter.StatementHandle.execute(Unknown Source) at com.apusic.esb.base.util.SQLUtil.createDBObjectIfNecessary(SQLUtil.java:263) at com.apusic.esb.base.util.SQLUtil.createDBObjectIfNecessary(SQLUtil.java:225) at com.apusic.esb.config.trigger.mysql.MySqlTriggerManager.createTriggersIfNecessary(MySqlTriggerManager.java:83) at com.apusic.esb.config.trigger.TriggerConfigManager.deploy(TriggerConfigManager.java:331) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at com.apusic.esb.base.communication.CommInvokeUtil.invoke(CommInvokeUtil.java:139) at com.apusic.esb.base.communication.CommInvokeUtil.invoke(CommInvokeUtil.java:43) at com.apusic.esb.base.communication.CommInvokeUtil.invoke(CommInvokeUtil.java:27) at com.apusic.esb.base.communication.socket.server.CommSocketServer$RequestProcessor.run(CommSocketServer.java:99) at com.apusic.util.ThreadPoolImpl$WorkerThread.run(Unknown Source)
分析下,首先怀疑是否驱动的问题,因为,驱动确实存在不匹配的问题,驱动的版本较低(针对5.0),而服务器版本为5.5,替换驱动之后问题依旧。
其次,分析错误信息本身,不允许执行神马命令,看起来貌似是权限问题,Navicat连接数据库,查看用户权限,发现用户“root@%”的“Trigger”一栏未选中!而此次连接的用户,看起来是“root@mortimer-PC”,因此,“root@localhost”的规则,貌似不会生效,估计是此原因,造成无法创建触发器。
调整“root@%”用户的权限,选中“Trigger”栏,重启MySQL服务,重新连接MySQL,创建触发器,OK!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Full table scanning may be faster in MySQL than using indexes. Specific cases include: 1) the data volume is small; 2) when the query returns a large amount of data; 3) when the index column is not highly selective; 4) when the complex query. By analyzing query plans, optimizing indexes, avoiding over-index and regularly maintaining tables, you can make the best choices in practical applications.

InnoDB's full-text search capabilities are very powerful, which can significantly improve database query efficiency and ability to process large amounts of text data. 1) InnoDB implements full-text search through inverted indexing, supporting basic and advanced search queries. 2) Use MATCH and AGAINST keywords to search, support Boolean mode and phrase search. 3) Optimization methods include using word segmentation technology, periodic rebuilding of indexes and adjusting cache size to improve performance and accuracy.

Yes, MySQL can be installed on Windows 7, and although Microsoft has stopped supporting Windows 7, MySQL is still compatible with it. However, the following points should be noted during the installation process: Download the MySQL installer for Windows. Select the appropriate version of MySQL (community or enterprise). Select the appropriate installation directory and character set during the installation process. Set the root user password and keep it properly. Connect to the database for testing. Note the compatibility and security issues on Windows 7, and it is recommended to upgrade to a supported operating system.

The difference between clustered index and non-clustered index is: 1. Clustered index stores data rows in the index structure, which is suitable for querying by primary key and range. 2. The non-clustered index stores index key values and pointers to data rows, and is suitable for non-primary key column queries.

Article discusses popular MySQL GUI tools like MySQL Workbench and phpMyAdmin, comparing their features and suitability for beginners and advanced users.[159 characters]

Article discusses strategies for handling large datasets in MySQL, including partitioning, sharding, indexing, and query optimization.

MySQL is an open source relational database management system. 1) Create database and tables: Use the CREATEDATABASE and CREATETABLE commands. 2) Basic operations: INSERT, UPDATE, DELETE and SELECT. 3) Advanced operations: JOIN, subquery and transaction processing. 4) Debugging skills: Check syntax, data type and permissions. 5) Optimization suggestions: Use indexes, avoid SELECT* and use transactions.

In MySQL database, the relationship between the user and the database is defined by permissions and tables. The user has a username and password to access the database. Permissions are granted through the GRANT command, while the table is created by the CREATE TABLE command. To establish a relationship between a user and a database, you need to create a database, create a user, and then grant permissions.
