Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I installed LAMP server on my Ubuntu 12.04 Server PC. I changed the database storage location using my.cnf. After I changed the location it's working fine. But if I restart my MySQL database is deleted and my database shows empty. I don't know why it happened, after I imported the dumb data to my previously created database, it shows the following error:


 `usna` VARCHAR( 100 ) NOT NULL ,
 `pas` VARCHAR( 100 ) NOT NULL

MySQL said: Documentation

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

...but if create a new database and after that I import the data again, it will work fine. Is my my.cnf file wrong? Please tell me how to fix this.

MY.cnf file

# 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.
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.
socket      = /var/run/mysqld/mysqld.sock
nice        = 0

# * 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
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address        =
# * 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
# 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

max_allowed_packet  = 16M

#no-auto-rehash # faster start of mysql but no tab completition

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/
share|improve this question

2 Answers 2

I just ran into a problem somewhat similar to this. Now, I'm not entirely sure if this will fix your problem, but it helped mine! Basically what happened in my situation was: When I went to restart my Ubuntu Server, I would go into my databases only to find the data was missing.. even though I just recently had added some to it. So I did some digging around and for each Table, clicked on Operations (mixed in with the tabs up top), and noticed a property called Storage Engine. It was initially set to Memory, which seemed off to me. So I checked my other databases and noticed they were all set to InnoDB. So I changed the tables, in the Database I was having problems with, to InnoDB and restarted my server to test check them. The data was now saving with no problems!

Again, not sure if this answers your question, but hopefully it will help anyone digging around the internet for a solution to this same problem I was facing.

share|improve this answer

I had a similar issue: no problems importing dumps but on 3 Ubuntu 14.04 MySQL servers, the databases disappeared after a reboot. During the initial setup, I had changed my.cnf to point to a new database location, disabled MySQL in Apparmor and used 'sudo /etc/init.d/mysql restart' to update MySQL.

The problem is /etc/init.d/mysql no longer properly stops mysqld--you need to use 'sudo restart mysql' to use Upstart instead of init. It turns out all the database data was accumulating in the default /var/lib/mysql location. Once the server was rebooted, my.cnf finally started pointing to the new location for the first time, which was empty and never populated.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.