简体   繁体   中英

(1231) Variable 'time_zone' can't be set to the value of 'NULL'

I dumped a database from my linux machine and i import it in my localhost, but after the import when i try to execute query from the site or phpmyadmin i receive this error:

(1231) Variable 'time_zone' can't be set to the value of 'NULL'

I read a lot and i didn't find any selution that worked for me.. I try to import the database like

sourde dump.sql

i tried with

mysql -u root -p database < dump.sql

I tried to increase max_allowed_packet a lot. Last one i set it to 1024 1024 1024 I tried with

    /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;

But still nothing work.. Is there any other selution that i can try? Also i didn't understand what exactly is the problem and why this error appear?

In the beggining of the sql dump i have the following code:

    /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;

In the end of the file i have

/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;

/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;

In the table user i have one trigger witch is setting this variable and the code start like this:

DROP TRIGGER IF EXISTS `user_rank_upd`;
DELIMITER //
CREATE TRIGGER `user_rank_upd` AFTER UPDATE ON `user`
 FOR EACH ROW BEGIN

                    DECLARE c_offset TEXT;
                    SET c_offset = TIMESTAMPDIFF(HOUR, UTC_TIMESTAMP(), CONVERT_TZ(UTC_TIMESTAMP(), 'UTC', 'Europe/Sofia'));
                    SET time_zone = CONCAT(IF(c_offset > 0, '+', '-'), TIME_FORMAT(MAKETIME(ABS(c_offset), 0, 0), '%H:%S'));....

When inserting into your database the variable time_zone contains the word NULL which means it's empty The database is expecting an input for it.

Post your create table code and we can take a look. The code will look like below.

CREATE TABLE `Banned` (
  `Block` int(11) NOT NULL,
  `BlockedID` varchar(100) NOT NULL

) ENGINE=MyISAM DEFAULT CHARSET=utf8;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM