1

我在我的 Ubuntu 12.04 服务器 PC 上安装了 LAMP 服务器。我使用 my.cnf 更改了数据库存储位置。更改位置后,它工作正常。但是如果我重新启动我的 MySQL 数据库被删除并且我的数据库显示为空。我不知道为什么会这样,在我将哑数据导入之前创建的数据库后,它显示以下错误:

CREATE TABLE IF NOT EXISTS  `admin` (

 `usna` VARCHAR( 100 ) NOT NULL ,
 `pas` VARCHAR( 100 ) NOT NULL
) ENGINE = INNODB DEFAULT CHARSET = latin1;

MySQL said: Documentation

#1146 - Table 'admin_db.admin' doesn't exist

...但是如果创建一个新数据库,然后我再次导入数据,它将正常工作。我的 my.cnf 文件错了吗?请告诉我如何解决这个问题。

我的.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     = /media/sdc1/Mysql
tmpdir      = /tmp
lc-messages-dir = /usr/share/mysql
default-storage-engine=InnoDB
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      = 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         = 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 = /media/sdc1/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/

我的辅助数据库目录列表

/media/sdc1/Mysql/mysql
/media/sdc1/Mysql/new
/media/sdc1/Mysql/performance_schema
/media/sdc1/Mysql/phpmyadmin
/media/sdc1/Mysql/test
/media/sdc1/Mysql/_testtmj
/media/sdc1/Mysql/columns_priv.frm
/media/sdc1/Mysql/columns_priv.MYD
/media/sdc1/Mysql/columns_priv.MYI
/media/sdc1/Mysql/db.frm
/media/sdc1/Mysql/db.MYD
/media/sdc1/Mysql/db.MYI
/media/sdc1/Mysql/debian-5.5.flag
/media/sdc1/Mysql/event.frm
/media/sdc1/Mysql/event.MYD
/media/sdc1/Mysql/event.MYI
/media/sdc1/Mysql/func.frm
/media/sdc1/Mysql/func.MYD
/media/sdc1/Mysql/func.MYI
/media/sdc1/Mysql/general_log.CSM
/media/sdc1/Mysql/general_log.CSV
/media/sdc1/Mysql/general_log.frm
/media/sdc1/Mysql/help_category.frm
/media/sdc1/Mysql/help_category.MYD
/media/sdc1/Mysql/help_category.MYI
/media/sdc1/Mysql/help_keyword.frm
/media/sdc1/Mysql/help_keyword.MYD
/media/sdc1/Mysql/help_keyword.MYI
/media/sdc1/Mysql/help_relation.frm
/media/sdc1/Mysql/help_relation.MYD
/media/sdc1/Mysql/help_relation.MYI
/media/sdc1/Mysql/help_topic.frm
/media/sdc1/Mysql/help_topic.MYD
/media/sdc1/Mysql/help_topic.MYI
/media/sdc1/Mysql/host.frm
/media/sdc1/Mysql/host.MYD
/media/sdc1/Mysql/host.MYI
/media/sdc1/Mysql/ibdata
/media/sdc1/Mysql/ibdata1
/media/sdc1/Mysql/ib_logfile0
/media/sdc1/Mysql/ib_logfile1
/media/sdc1/Mysql/mysql_upgrade_info
/media/sdc1/Mysql/ndb_binlog_index.frm
/media/sdc1/Mysql/ndb_binlog_index.MYD
/media/sdc1/Mysql/ndb_binlog_index.MYI
/media/sdc1/Mysql/plugin.frm
/media/sdc1/Mysql/plugin.MYD
/media/sdc1/Mysql/plugin.MYI
/media/sdc1/Mysql/proc.frm
/media/sdc1/Mysql/proc.MYD
/media/sdc1/Mysql/proc.MYI
/media/sdc1/Mysql/procs_priv.frm
/media/sdc1/Mysql/procs_priv.MYD
/media/sdc1/Mysql/procs_priv.MYI
/media/sdc1/Mysql/proxies_priv.frm
/media/sdc1/Mysql/proxies_priv.MYD
/media/sdc1/Mysql/proxies_priv.MYI
/media/sdc1/Mysql/SERVER.err
/media/sdc1/Mysql/SERVER.pid
/media/sdc1/Mysql/servers.frm
/media/sdc1/Mysql/servers.MYD
/media/sdc1/Mysql/servers.MYI
/media/sdc1/Mysql/slow_log.CSM
/media/sdc1/Mysql/slow_log.CSV
/media/sdc1/Mysql/slow_log.frm
/media/sdc1/Mysql/tables_priv.frm
/media/sdc1/Mysql/tables_priv.MYD
/media/sdc1/Mysql/tables_priv.MYI
/media/sdc1/Mysql/time_zone.frm
/media/sdc1/Mysql/time_zone.MYD
/media/sdc1/Mysql/time_zone.MYI
/media/sdc1/Mysql/time_zone_leap_second.frm
/media/sdc1/Mysql/time_zone_leap_second.MYD
/media/sdc1/Mysql/time_zone_leap_second.MYI
/media/sdc1/Mysql/time_zone_name.frm
/media/sdc1/Mysql/time_zone_name.MYD
/media/sdc1/Mysql/time_zone_name.MYI
/media/sdc1/Mysql/time_zone_transition.frm
/media/sdc1/Mysql/time_zone_transition.MYD
/media/sdc1/Mysql/time_zone_transition.MYI
/media/sdc1/Mysql/time_zone_transition_type.frm
/media/sdc1/Mysql/time_zone_transition_type.MYD
/media/sdc1/Mysql/time_zone_transition_type.MYI
/media/sdc1/Mysql/user.frm
/media/sdc1/Mysql/user.MYD
/media/sdc1/Mysql/user.MYI
4

1 回答 1

0

您可能需要更改innodb_data_home_dir或的默认值innodb_data_file_path

检查输出SELECT @@innodb_data_home_dir, @@innodb_data_file_path并在需要时更改它们(如果innodb_data_home_dirNULL,则默认为datadir)。

于 2013-09-03T07:36:31.573 回答