search
HomeDatabasephpMyAdminSolve the problems encountered by phpMyadmin in creating triggers for MySQL data tables

The following tutorial column of phpmyadmin will introduce to you the problems encountered in using phpMyadmin to create triggers for MySQL data tables. I hope it will be helpful to friends in need!

Solve the problems encountered by phpMyadmin in creating triggers for MySQL data tables

Today I created a trigger for the table in the MySQL database. The desired effect is: after modifying the received field in table a, the registerStatus in table b must also be changed. Updated to 1, change registerIP to receive value.

1. First write the sql statement to create the trigger:

1) When inserting:

CREATE TRIGGER insertref BEFORE INSERT ON a
 FOR EACH ROW BEGIN 
UPDATE b SET registerStatus =1 WHERE NEW.id = id and NEW.received is not null and NEW.received !='';
update b set registerIP=NEW.received where NEW.id = id;
end

2) When deleting:

CREATE TRIGGER deleteref BEFORE DELETE ON a
 FOR EACH ROW begin
update b set registerStatus =0 WHERE OLD.id = id;
update  b set registerIP=NULL where OLD.id = id;
end

3) When updating:

CREATE TRIGGER updateref  BEFORE UPDATE ON a
 FOR EACH ROW BEGIN 
update b set registerIP=NEW.received where OLD.id=id;
end

Question 1: When

finishes writing the statement and executes it, an error is reported and cannot be executed. The reason is that when using phpMyAdmin to create a trigger, you need to

Enter // in the Delimiter at the bottom of the sql statement page.

Question 2: After setting up the trigger, during testing, data cannot be inserted into table a, and an error message is reported:

1558 - Column count of mysql.proc is wrong. Expected 20, found 16. Created with MySQL 50018, now running 50146. Please use mysql_upgrade to fix this error.

There are many posts on the Internet saying that it is because of previous upgrades. The database, but the data structure has not been upgraded.

Solution: Execute sudo mysql_upgrade -u root -p to prompt for a password. After entering the password, restart the database. Then you can insert data.

The above is the detailed content of Solve the problems encountered by phpMyadmin in creating triggers for MySQL data tables. For more information, please follow other related articles on the PHP Chinese website!

Statement
This article is reproduced at:csdn. If there is any infringement, please contact admin@php.cn delete
phpMyAdmin: An Introduction to the Database Management ToolphpMyAdmin: An Introduction to the Database Management ToolApr 28, 2025 am 12:27 AM

phpMyAdmin simplifies MySQL database management through the web interface. 1) Create, modify, and delete databases and tables; 2) Execute SQL queries; 3) Import and export data; 4) Manage user permissions. It interacts with MySQL through a web server, providing an intuitive operation interface.

phpMyAdmin: A Web-Based Interface for Database ManagementphpMyAdmin: A Web-Based Interface for Database ManagementApr 27, 2025 am 12:20 AM

phpMyAdmin is a web-based tool for managing MySQL and MariaDB databases. 1) It provides an intuitive user interface that allows various database operations through the browser. 2) phpMyAdmin interacts with the database through PHP scripts and converts operations into SQL commands. 3) Users can perform operations from basic data browsing and editing to advanced SQL queries and view management. 4) Common problems include connection failures and SQL syntax errors, which can be solved by checking configuration and syntax. 5) Performance optimization suggestions include avoiding large-scale data operations during peak periods and regularly maintaining databases.

phpMyAdmin: Managing Tables, Databases, and UsersphpMyAdmin: Managing Tables, Databases, and UsersApr 26, 2025 am 12:01 AM

phpMyAdmin can be used to manage tables, databases, and users. 1) Create a table: Create a table named users through the interface, including id, username and email fields. 2) Export database: Export the structure and data of my_database and its users table. 3) Manage users: Create a new user and grant them all permissions to my_database.

Using phpMyAdmin: A Guide for Database AdministratorsUsing phpMyAdmin: A Guide for Database AdministratorsApr 25, 2025 am 12:12 AM

phpMyAdmin is a web-based MySQL database management tool that provides an intuitive interface to manage databases. 1. It allows creating, modifying, deleting databases and tables, executing SQL queries, importing and exporting data, performing user management and permission settings. 2. By establishing a connection with the MySQL server, phpMyAdmin converts user requests into SQL commands and executes them. 3. The basic usage includes viewing table data, and the advanced usage supports complex SQL queries. 4. Common errors such as connection failure and query syntax errors can be debugged by checking the server status and using the SQL editor. 5. Performance optimization can be achieved by creating indexes for common fields, regularly backing up the database, and keeping the structure neat.

Understanding the Relationship: MySQL and phpMyAdminUnderstanding the Relationship: MySQL and phpMyAdminApr 24, 2025 am 12:05 AM

The relationship between MySQL and phpMyAdmin is that MySQL stores data, and phpMyAdmin manages this data through the HTTP protocol. 1.MySQL is an open source relational database management system that supports a variety of operating systems and project requirements. 2.phpMyAdmin is a web-based tool that provides an intuitive interface to manage MySQL databases, and supports SQL queries and data import and export. 3.phpMyAdmin communicates with the MySQL server by generating SQL queries, and users can operate the database through the interface. 4. Use phpMyAdmin to create databases and tables, execute queries, import and export data, and support advanced features such as optimized queries and management permissions.

phpMyAdmin and MySQL: The Perfect CombinationphpMyAdmin and MySQL: The Perfect CombinationApr 23, 2025 am 12:04 AM

phpMyAdminandMySQLtogetherenhancedatabasemanagementbyprovidingeaseandefficiency.1)phpMyAdminoffersauser-friendlyinterfaceformanagingMySQLdatabases,2)itallowsforeasyexecutionofSQLqueries,import/exportofdatabases,andmanagementofuserpermissions,3)itaids

MySQL and phpMyAdmin: Core Features and FunctionsMySQL and phpMyAdmin: Core Features and FunctionsApr 22, 2025 am 12:12 AM

MySQL and phpMyAdmin are powerful database management tools. 1) MySQL is used to create databases and tables, and to execute DML and SQL queries. 2) phpMyAdmin provides an intuitive interface for database management, table structure management, data operations and user permission management.

phpMyAdmin: Generating and Executing SQL QueriesphpMyAdmin: Generating and Executing SQL QueriesApr 21, 2025 am 12:03 AM

The methods of generating and executing SQL queries in phpMyAdmin include: 1. Enter the query in the SQL tab and click to execute; 2. Use JOIN to merge table data; 3. Use index and LIMIT when optimizing queries. phpMyAdmin simplifies database management through an intuitive interface, supporting SQL query operations from basic to advanced.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Tools

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor