修改mysql默认的数据库存储位置后不能启动

Web、Mail、Ftp、DNS、Proxy、VPN、Samba、LDAP 等基础网络服务
回复
qiushui_90
帖子: 55
注册时间: 2012-11-19 9:46
系统: Ubuntu server 12

修改mysql默认的数据库存储位置后不能启动

#1

帖子 qiushui_90 » 2013-08-02 0:49

操作系统为ubuntu 11.10,使用apt-get安装的mysql,之前可以正常使用,现在由于数据库交大,需要将数据库的存储位置修改到其他地方,我参考这个帖子进行了修改。http://linux.ctocio.com.cn/35/8719035.shtml
1、在执行$sudo /etc/init.d/apparmor reload这个命令式出错,出错信息为:
/etc/init.d/apparmor: line 35: /etc/apparmor/functions: No such file or directory
2、重新启动mysql,没有报错,但是并没有找打mysql的进程。
3、我再去登录mysql的时候,就报出了如下的错误:ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
请大家帮帮忙吧,这个服务器比较重要,得尽快弄好啊…………
走你~
帖子: 16
注册时间: 2012-11-30 23:39

Re: 修改mysql默认的数据库存储位置后不能启动

#2

帖子 走你~ » 2013-08-02 9:41

把你的mysql配置文件和apparmor配置文件放上来看看
qiushui_90
帖子: 55
注册时间: 2012-11-19 9:46
系统: Ubuntu server 12

Re: 修改mysql默认的数据库存储位置后不能启动

#3

帖子 qiushui_90 » 2013-08-02 10:14

走你~ 写了:把你的mysql配置文件和apparmor配置文件放上来看看
[client]
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/serve ... ables.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
#socket = /tmp/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
#

#
# * IMPORTANT
# If you make changes to these settings and your system uses apparmor, you may
# also need to also adjust /etc/apparmor.d/usr.sbin.mysqld.
#

user = mysql
socket = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr
#datadir = /data/tvinfo/mysql
datadir = /var/lib/mysql
tmpdir = /tmp
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 = 0.0.0.0
#
# * 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

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/



apparmor文件:
# vim:syntax=apparmor
# Last Modified: Tue Jun 19 17:37:30 2007
#include <tunables/global>

/usr/sbin/mysqld {
#include <abstractions/base>
#include <abstractions/nameservice>
#include <abstractions/user-tmp>
#include <abstractions/mysql>
#include <abstractions/winbind>

capability dac_override,
capability sys_resource,
capability setgid,
capability setuid,

network tcp,

/etc/hosts.allow r,
/etc/hosts.deny r,

/etc/mysql/*.pem r,
/etc/mysql/conf.d/ r,
/etc/mysql/conf.d/* r,
/etc/mysql/my.cnf r,
/usr/lib/mysql/plugin/ r,
/usr/lib/mysql/plugin/*.so* mr,
/usr/sbin/mysqld mr,
/usr/share/mysql/** r,
/var/log/mysql.log rw,
/var/log/mysql.err rw,
/var/lib/mysql/ r,
/var/lib/mysql/** rwk,
# /data/tvinfo/mysql/ r,
# /data/tvinfo/mysql/** rwk,
/var/log/mysql/ r,
/var/log/mysql/* rw,
# /{,var/}run/mysqld/mysqld.pid w,
# /{,var/}run/mysqld/mysqld.sock w,
/var/run/mysqld/mysqld.pid w,
/var/run/mysqld/mysqld.sock w,
/sys/devices/system/cpu/ r,

# Site-specific additions and overrides. See local/README for details.
#include <local/usr.sbin.mysqld>
}

走你~
帖子: 16
注册时间: 2012-11-30 23:39

Re: 修改mysql默认的数据库存储位置后不能启动

#4

帖子 走你~ » 2013-08-02 23:27

1、在执行$sudo /etc/init.d/apparmor reload这个命令式出错,出错信息为:
/etc/init.d/apparmor: line 35: /etc/apparmor/functions: No such file or directory
这个问题还在么?

你把配置文件改回去后有没有执行$sudo /etc/init.d/apparmor reload?

再重启试试
走你~
帖子: 16
注册时间: 2012-11-30 23:39

Re: 修改mysql默认的数据库存储位置后不能启动

#5

帖子 走你~ » 2013-08-03 7:10

3、我再去登录mysql的时候,就报出了如下的错误:ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
试了下,没有启动mysql服务会出现这种情况,与apparmor配置无关
执行sudo /etc/init.d/mysql start试试
qiushui_90
帖子: 55
注册时间: 2012-11-19 9:46
系统: Ubuntu server 12

Re: 修改mysql默认的数据库存储位置后不能启动

#6

帖子 qiushui_90 » 2013-08-22 18:34

最后发现删除数据库存储路径下的log文件就好了,谢谢各位了
回复