我有一个MySql数据库 服务器版本:5.5.47-0ubuntu0.14.04.1(Ubuntu) 和表中的城市。
我正在使用Spring-MVC - hibernate,所以我正在对@entity注释中的数据库进行更改。
我第一次创建表时,我创建了列#34; name" :
CREATE TABLE `City` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(45) DEFAULT NULL,
`stateId` int(11) NOT NULL,
PRIMARY KEY (`id`),
KEY `FK_tr4eopukpxbiked4okmvk3txd` (`stateId`),
CONSTRAINT `FK_tr4eopukpxbiked4okmvk3txd` FOREIGN KEY (`stateId`) REFERENCES `State` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
几天后,我更改了专栏" name" to" nameEn"我添加了列" nameLc" :
CREATE TABLE `City` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`nameEn` varchar(45) DEFAULT NULL,
`nameLc` varchar(45) DEFAULT NULL,
`stateId` int(11) NOT NULL,
PRIMARY KEY (`id`),
KEY `FK_tr4eopukpxbiked4okmvk3txd` (`stateId`),
CONSTRAINT `FK_tr4eopukpxbiked4okmvk3txd` FOREIGN KEY (`stateId`) REFERENCES `State` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8;
从那天开始,每次重新启动计算机时,此表(以及其他一些具有相同更改的表)都会返回到第一个状态:
CREATE TABLE `City` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(45) DEFAULT NULL,
`stateId` int(11) NOT NULL,
PRIMARY KEY (`id`),
KEY `FK_tr4eopukpxbiked4okmvk3txd` (`stateId`),
CONSTRAINT `FK_tr4eopukpxbiked4okmvk3txd` FOREIGN KEY (`stateId`) REFERENCES `State` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
当我重新启动服务时不会发生错误,只有在我重新启动计算机时才会发生这种情况(ubuntu)
这是error.log:
160219 8:59:34 [Note] /usr/sbin/mysqld: Normal shutdown
160219 8:59:34 [Note] Event Scheduler: Purging the queue. 0 events
160219 8:59:34 InnoDB: Starting shutdown...
160219 8:59:36 InnoDB: Shutdown completed; log sequence number 2507506155
160219 8:59:36 [Note] /usr/sbin/mysqld: Shutdown complete
160219 8:59:36 [Note] Plugin 'FEDERATED' is disabled.
160219 8:59:36 InnoDB: The InnoDB memory heap is disabled
160219 8:59:36 InnoDB: Mutexes and rw_locks use GCC atomic builtins
160219 8:59:36 InnoDB: Compressed tables use zlib 1.2.8
160219 8:59:36 InnoDB: Using Linux native AIO
160219 8:59:36 InnoDB: Initializing buffer pool, size = 128.0M
160219 8:59:36 InnoDB: Completed initialization of buffer pool
160219 8:59:36 InnoDB: highest supported file format is Barracuda.
160219 8:59:36 InnoDB: Waiting for the background threads to start
160219 8:59:37 InnoDB: 5.5.47 started; log sequence number 2507506155
160219 8:59:37 [Note] Server hostname (bind-address): '127.0.0.1'; port: 3306
160219 8:59:37 [Note] - '127.0.0.1' resolves to '127.0.0.1';
160219 8:59:37 [Note] Server socket created on IP: '127.0.0.1'.
160219 8:59:37 [Note] Event Scheduler: Loaded 0 events
160219 8:59:37 [Note] /usr/sbin/mysqld: ready for connections.
Version: '5.5.47-0ubuntu0.14.04.1' socket: '/var/run/mysqld/mysqld.sock' port: 3306 (Ubuntu)
160219 9:09:39 [Note] /usr/sbin/mysqld: Normal shutdown
160219 9:09:39 [Note] Event Scheduler: Purging the queue. 0 events
160219 9:09:39 InnoDB: Starting shutdown...
160219 9:09:41 InnoDB: Shutdown completed; log sequence number 2509266518
160219 9:09:41 [Note] /usr/sbin/mysqld: Shutdown complete
160219 9:09:41 [Note] Plugin 'FEDERATED' is disabled.
160219 9:09:41 InnoDB: The InnoDB memory heap is disabled
160219 9:09:41 InnoDB: Mutexes and rw_locks use GCC atomic builtins
160219 9:09:41 InnoDB: Compressed tables use zlib 1.2.8
160219 9:09:41 InnoDB: Using Linux native AIO
160219 9:09:41 InnoDB: Initializing buffer pool, size = 128.0M
160219 9:09:41 InnoDB: Completed initialization of buffer pool
160219 9:09:41 InnoDB: highest supported file format is Barracuda.
160219 9:09:41 InnoDB: Waiting for the background threads to start
160219 9:09:42 InnoDB: 5.5.47 started; log sequence number 2509266518
160219 9:09:42 [Note] Server hostname (bind-address): '127.0.0.1'; port: 3306
160219 9:09:42 [Note] - '127.0.0.1' resolves to '127.0.0.1';
160219 9:09:42 [Note] Server socket created on IP: '127.0.0.1'.
160219 9:09:42 [Note] Event Scheduler: Loaded 0 events
160219 9:09:42 [Note] /usr/sbin/mysqld: ready for connections.
Version: '5.5.47-0ubuntu0.14.04.1' socket: '/var/run/mysqld/mysqld.sock' port: 3306 (Ubuntu)
160219 9:13:10 [Note] /usr/sbin/mysqld: Normal shutdown
160219 9:13:10 [Note] Event Scheduler: Purging the queue. 0 events
160219 9:13:10 InnoDB: Starting shutdown...
160219 9:13:11 InnoDB: Shutdown completed; log sequence number 2509266518
160219 9:13:11 [Note] /usr/sbin/mysqld: Shutdown complete
160219 9:13:48 [Note] Plugin 'FEDERATED' is disabled.
160219 9:13:48 InnoDB: The InnoDB memory heap is disabled
160219 9:13:48 InnoDB: Mutexes and rw_locks use GCC atomic builtins
160219 9:13:48 InnoDB: Compressed tables use zlib 1.2.8
160219 9:13:48 InnoDB: Using Linux native AIO
160219 9:13:48 InnoDB: Initializing buffer pool, size = 128.0M
160219 9:13:48 InnoDB: Completed initialization of buffer pool
160219 9:13:48 InnoDB: highest supported file format is Barracuda.
160219 9:13:48 InnoDB: Waiting for the background threads to start
160219 9:13:49 InnoDB: 5.5.47 started; log sequence number 2509266518
160219 9:13:49 [Note] Server hostname (bind-address): '127.0.0.1'; port: 3306
160219 9:13:49 [Note] - '127.0.0.1' resolves to '127.0.0.1';
160219 9:13:49 [Note] Server socket created on IP: '127.0.0.1'.
160219 9:13:49 [Note] Event Scheduler: Loaded 0 events
160219 9:13:49 [Note] /usr/sbin/mysqld: ready for connections.
Version: '5.5.47-0ubuntu0.14.04.1' socket: '/var/run/mysqld/mysqld.sock' port: 3306 (Ubuntu)
my.cnf文件是:
#
# The MySQL database server configuration file.
#
# You can copy this to one of:
# - "/etc/mysql/my.cnf" to set global options,
# - "~/.my.cnf" to set user-specific options.
#
# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html
# This will be passed to all mysql clients
# It has been reported that passwords should be enclosed with ticks/quotes
# escpecially if they contain "#" chars...
# Remember to edit /etc/mysql/debian.cnf when changing the socket location.
[client]
port = 3306
socket = /var/run/mysqld/mysqld.sock
# Here is entries for some specific programs
# The following values assume you have at least 32M ram
# This was formally known as [safe_mysqld]. Both versions are currently parsed.
[mysqld_safe]
socket = /var/run/mysqld/mysqld.sock
nice = 0
[mysqld]
#
# * Basic Settings
#
user = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
character_set_server = utf8 # If you prefer utf8
collation_server = utf8_general_ci
lc-messages-dir = /usr/share/mysql
skip-external-locking
#
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address = 127.0.0.1
#
# * Fine Tuning
#
key_buffer_size = 16M
max_allowed_packet = 16M
thread_stack = 192K
thread_cache_size = 8
# This replaces the startup script and checks MyISAM tables if needed
# the first time they are touched
myisam-recover_options = BACKUP
#max_connections = 100
#table_cache = 64
#thread_concurrency = 10
#
# * Query Cache Configuration
#
query_cache_limit = 1M
query_cache_size = 16M
#
# * Logging and Replication
#
# Both location gets rotated by the cronjob.
# Be aware that this log type is a performance killer.
# As of 5.1 you can enable the log at runtime!
#general_log_file = /var/log/mysql/mysql.log
#general_log = 1
#
# Error log - should be very few entries.
#
log_error = /var/log/mysql/error.log
#
# Here you can see queries with especially long duration
#log_slow_queries = /var/log/mysql/mysql-slow.log
#long_query_time = 2
#log-queries-not-using-indexes
#
# The following can be used as easy to replay backup logs or for replication.
# note: if you are setting up a replication slave, see README.Debian about
# other settings you may need to change.
#server-id = 1
#log_bin = /var/log/mysql/mysql-bin.log
expire_logs_days = 10
max_binlog_size = 100M
#binlog_do_db = include_database_name
#binlog_ignore_db = include_database_name
#
# * InnoDB
#
# InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/.
# Read the manual for more InnoDB related options. There are many!
#
# * Security Features
#
# Read the manual, too, if you want chroot!
# chroot = /var/lib/mysql/
#
# For generating SSL certificates I recommend the OpenSSL GUI "tinyca".
#
# ssl-ca=/etc/mysql/cacert.pem
# ssl-cert=/etc/mysql/server-cert.pem
# ssl-key=/etc/mysql/server-key.pem
[mysqldump]
quick
quote-names
max_allowed_packet = 16M
[mysql]
#no-auto-rehash # faster start of mysql but no tab completition
[isamchk]
key_buffer = 16M
#
# * IMPORTANT: Additional settings that can override those from this file!
# The files must end with '.cnf', otherwise they'll be ignored.
#
!includedir /etc/mysql/conf.d/
你可以帮助我理解并解决这个错误吗?
答案 0 :(得分:0)
MySQL允许您创建具有现有名称的临时表。当您尝试创建与现有名称相同的表时,MySQL可能会创建临时表。只在会话中显示临时表,因此在重新启动计算机后,它将被删除。
如果您想对现有的表格使用进行更改:
ALTER TABLE
答案 1 :(得分:0)
由于我没有找到问题的原因,我终于使用不同的名称创建了现有数据库的副本,问题就消失了。