[Question] howto change mysql datadir |
05/05/2008 20:26:23 (+0700) | #1 | 128985 |
3do
Member
|
0 |
|
|
Joined: 19/04/2008 21:57:09
Messages: 24
Offline
|
|
Tôi muốn thay đổi thư mục datadir của mysql sang 1 nơi khác. Tôi đã thử đổi biến datadir trong file config sang nơi mới, chown và chmod đầy đủ nhưng khi start mysql báo fail
trong syslog
Code:
May 5 07:21:22 pliersn-laptop mysqld_safe[7709]: started
May 5 07:21:22 pliersn-laptop kernel: [ 3430.063863] audit(1209946882.531:6): type=1503 operation="inode_create" requested_mask="w::" denied_mask="w::" name="/data/mysql/pliersn-laptop.lower-test" pid=7711 profile="/usr/sbin/mysqld" namespace="default"
May 5 07:21:22 pliersn-laptop mysqld[7713]: 080505 7:21:22 [Warning] Can't create test file /data/mysql/pliersn-laptop.lower-test
May 5 07:21:22 pliersn-laptop kernel: [ 3430.066267] audit(1209946882.531:7): type=1503 operation="inode_create" requested_mask="w::" denied_mask="w::" name="/data/mysql/pliersn-laptop.lower-test" pid=7711 profile="/usr/sbin/mysqld" namespace="default"
May 5 07:21:22 pliersn-laptop mysqld[7713]: 080505 7:21:22 [Warning] Can't create test file /data/mysql/pliersn-laptop.lower-test
May 5 07:21:22 pliersn-laptop kernel: [ 3430.094495] audit(1209946882.559:8): type=1503 operation="inode_create" requested_mask="w::" denied_mask="w::" name="/data/mysql/ibdata1" pid=7711 profile="/usr/sbin/mysqld" namespace="default"
May 5 07:21:22 pliersn-laptop mysqld[7713]: 080505 7:21:22 InnoDB: Operating system error number 13 in a file operation.
May 5 07:21:22 pliersn-laptop mysqld[7713]: InnoDB: The error means mysqld does not have the access rights to
May 5 07:21:22 pliersn-laptop mysqld[7713]: InnoDB: the directory.
May 5 07:21:22 pliersn-laptop mysqld[7713]: InnoDB: File name ./ibdata1
May 5 07:21:22 pliersn-laptop mysqld[7713]: InnoDB: File operation call: 'create'.
May 5 07:21:22 pliersn-laptop mysqld[7713]: InnoDB: Cannot continue operation.
May 5 07:21:22 pliersn-laptop mysqld_safe[7720]: ended
Tôi dùng hardy, file /etc/mysql/my.cnf của tôi
Code:
#
# 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
#
#
# * 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
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
language = /usr/share/mysql/english
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 = 128K
thread_cache_size = 8
#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.
#log = /var/log/mysql/mysql.log
#
# Error logging goes to syslog. This is a Debian improvement :)
#
# 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
#
# * BerkeleyDB
#
# Using BerkeleyDB is now discouraged as its support will cease in 5.1.12.
skip-bdb
#
# * 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!
# You might want to disable InnoDB to shrink the mysqld process by circa 100MB.
#skip-innodb
#
# * 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
#
# * NDB Cluster
#
# See /usr/share/doc/mysql-server-*/README.Debian for more information.
#
# The following configuration is read by the NDB Data Nodes (ndbd processes)
# not from the NDB Management Nodes (ndb_mgmd processes).
#
# [MYSQL_CLUSTER]
# ndb-connectstring=127.0.0.1
#
# * 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/
Xin giúp đỡ cách khắc phục
Cảm ơn |
|
|
 |
 |
[Question] Re: howto change mysql datadir |
05/05/2008 20:52:50 (+0700) | #2 | 128986 |
![[Avatar] [Avatar]](/hvaonline/images/avatar/089f41810321eefc3f4eef5d4a388e42.png)
|
conmale
Administrator
|
Joined: 07/05/2004 23:43:15
Messages: 9353
Location: down under
Offline
|
|
Nhìn vào log ở trên thì thấy rõ chown, chmod chưa đầy đủ. |
|
What bringing us together is stronger than what pulling us apart. |
|
[Question] Re: howto change mysql datadir |
05/05/2008 22:05:15 (+0700) | #3 | 128995 |
3do
Member
|
0 |
|
|
Joined: 19/04/2008 21:57:09
Messages: 24
Offline
|
|
Chào anh,
Em cũng ko biết như thế nào là "đầy đủ" theo ý anh
Code:
$ls /data -l|grep mysql
drwxr-xr-x 3 mysql mysql 4096 2008-05-04 22:16 mysql
$ls /data/mysql -l
total 4
drwxr-xr-x 2 mysql mysql 4096 2008-05-04 22:16 get
$ls /data/mysql/get -l
total 6736
-rwxr-xr-x 1 mysql mysql 8712 2008-05-04 22:16 xxx.frm
-rwxr-xr-x 1 mysql mysql 1433384 2008-05-04 22:16 xxx.MYD
-rwxr-xr-x 1 mysql mysql 1248256 2008-05-04 22:16 xxx.MYI
-rwxr-xr-x 1 mysql mysql 61 2008-05-04 22:16 db.opt
-rwxr-xr-x 1 mysql mysql 9006 2008-05-04 22:16 xxx.frm
-rwxr-xr-x 1 mysql mysql 2818732 2008-05-04 22:16 xxx.MYD
-rwxr-xr-x 1 mysql mysql 354304 2008-05-04 22:16 xxx.MYI
-rwxr-xr-x 1 mysql mysql 8618 2008-05-04 22:16 xxx.frm
-rwxr-xr-x 1 mysql mysql 400 2008-05-04 22:16 xxx.MYD
-rwxr-xr-x 1 mysql mysql 2048 2008-05-04 22:16 xxx.MYI
-rwxr-xr-x 1 mysql mysql 13042 2008-05-04 22:16 xxx.frm
-rwxr-xr-x 1 mysql mysql 3180 2008-05-04 22:16 xxx.MYD
-rwxr-xr-x 1 mysql mysql 2048 2008-05-04 22:16 xxx.MYI
-rwxr-xr-x 1 mysql mysql 8678 2008-05-04 22:16 xxx.frm
-rwxr-xr-x 1 mysql mysql 679892 2008-05-04 22:16 xxx.MYD
-rwxr-xr-x 1 mysql mysql 244736 2008-05-04 22:16 xxx.MYI
trong đó /data/mysql là datadir muốn chuyển đến |
|
|
 |
 |
[Question] Re: howto change mysql datadir |
05/05/2008 22:28:09 (+0700) | #4 | 129003 |
![[Avatar] [Avatar]](/hvaonline/images/avatar/089f41810321eefc3f4eef5d4a388e42.png)
|
conmale
Administrator
|
Joined: 07/05/2004 23:43:15
Messages: 9353
Location: down under
Offline
|
|
3do wrote:
Chào anh,
Em cũng ko biết như thế nào là "đầy đủ" theo ý anh
Code:
$ls /data -l|grep mysql
drwxr-xr-x 3 mysql mysql 4096 2008-05-04 22:16 mysql
$ls /data/mysql -l
total 4
drwxr-xr-x 2 mysql mysql 4096 2008-05-04 22:16 get
$ls /data/mysql/get -l
total 6736
-rwxr-xr-x 1 mysql mysql 8712 2008-05-04 22:16 xxx.frm
-rwxr-xr-x 1 mysql mysql 1433384 2008-05-04 22:16 xxx.MYD
-rwxr-xr-x 1 mysql mysql 1248256 2008-05-04 22:16 xxx.MYI
-rwxr-xr-x 1 mysql mysql 61 2008-05-04 22:16 db.opt
-rwxr-xr-x 1 mysql mysql 9006 2008-05-04 22:16 xxx.frm
-rwxr-xr-x 1 mysql mysql 2818732 2008-05-04 22:16 xxx.MYD
-rwxr-xr-x 1 mysql mysql 354304 2008-05-04 22:16 xxx.MYI
-rwxr-xr-x 1 mysql mysql 8618 2008-05-04 22:16 xxx.frm
-rwxr-xr-x 1 mysql mysql 400 2008-05-04 22:16 xxx.MYD
-rwxr-xr-x 1 mysql mysql 2048 2008-05-04 22:16 xxx.MYI
-rwxr-xr-x 1 mysql mysql 13042 2008-05-04 22:16 xxx.frm
-rwxr-xr-x 1 mysql mysql 3180 2008-05-04 22:16 xxx.MYD
-rwxr-xr-x 1 mysql mysql 2048 2008-05-04 22:16 xxx.MYI
-rwxr-xr-x 1 mysql mysql 8678 2008-05-04 22:16 xxx.frm
-rwxr-xr-x 1 mysql mysql 679892 2008-05-04 22:16 xxx.MYD
-rwxr-xr-x 1 mysql mysql 244736 2008-05-04 22:16 xxx.MYI
trong đó /data/mysql là datadir muốn chuyển đến
Thư mục bồ chuyển datadir là /data/mysql/. Trong khi đó, my.cnf có:
datadir = /var/lib/mysql
và logs thì cho biết:
May 5 07:21:22 pliersn-laptop mysqld[7713]: 080505 7:21:22 [Warning] Can't create test file /data/mysql/pliersn-laptop.lower-test
May 5 07:21:22 pliersn-laptop kernel: [ 3430.066267] audit(1209946882.531:7): type=1503 operation="inode_create" requested_mask="w::" denied_mask="w::" name="/data/mysql/pliersn-laptop.lower-test" pid=7711 profile="/usr/sbin/mysqld" namespace="default"
May 5 07:21:22 pliersn-laptop mysqld[7713]: 080505 7:21:22 [Warning] Can't create test file /data/mysql/pliersn-laptop.lower-test
May 5 07:21:22 pliersn-laptop kernel: [ 3430.094495] audit(1209946882.559:8): type=1503 operation="inode_create" requested_mask="w::" denied_mask="w::" name="/data/mysql/ibdata1" pid=7711 profile="/usr/sbin/mysqld" namespace="default"
Thì không đầy đủ là gì? |
|
What bringing us together is stronger than what pulling us apart. |
|
 |
 |
[Question] Re: howto change mysql datadir |
05/05/2008 22:35:16 (+0700) | #5 | 129005 |
3do
Member
|
0 |
|
|
Joined: 19/04/2008 21:57:09
Messages: 24
Offline
|
|
conmale wrote:
May 5 07:21:22 pliersn-laptop kernel: [ 3430.066267] audit(1209946882.531:7): type=1503 operation="inode_create" requested_mask="w::" denied_mask="w::" name="/data/mysql/pliersn-laptop.lower-test" pid=7711 profile="/usr/sbin/mysqld" namespace="default"
May 5 07:21:22 pliersn-laptop mysqld[7713]: 080505 7:21:22 [Warning] Can't create test file /data/mysql/pliersn-laptop.lower-test
May 5 07:21:22 pliersn-laptop kernel: [ 3430.094495] audit(1209946882.559:8): type=1503 operation="inode_create" requested_mask="w::" denied_mask="w::" name="/data/mysql/ibdata1" pid=7711 profile="/usr/sbin/mysqld" namespace="default"
Thì không đầy đủ là gì?
dòng datadir trong file my.cnf đó là trước khi chuyển. Sau khi sửa datadir
Code:
[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
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr
datadir = /data/mysql
tmpdir = /tmp
language = /usr/share/mysql/english
nó vẫn ko work |
|
|
 |
 |
[Question] Re: howto change mysql datadir |
05/05/2008 22:55:56 (+0700) | #6 | 129006 |
pnco
HVA Friend
|
Joined: 24/06/2005 16:33:48
Messages: 515
Offline
|
|
Bạn thử cho xem lại output của lệnh sau:
$ls -la /data |
|
|
[Question] Re: howto change mysql datadir |
05/05/2008 23:02:42 (+0700) | #7 | 129009 |
![[Avatar] [Avatar]](/hvaonline/images/avatar/089f41810321eefc3f4eef5d4a388e42.png)
|
conmale
Administrator
|
Joined: 07/05/2004 23:43:15
Messages: 9353
Location: down under
Offline
|
|
3do wrote:
conmale wrote:
May 5 07:21:22 pliersn-laptop kernel: [ 3430.066267] audit(1209946882.531:7): type=1503 operation="inode_create" requested_mask="w::" denied_mask="w::" name="/data/mysql/pliersn-laptop.lower-test" pid=7711 profile="/usr/sbin/mysqld" namespace="default"
May 5 07:21:22 pliersn-laptop mysqld[7713]: 080505 7:21:22 [Warning] Can't create test file /data/mysql/pliersn-laptop.lower-test
May 5 07:21:22 pliersn-laptop kernel: [ 3430.094495] audit(1209946882.559:8): type=1503 operation="inode_create" requested_mask="w::" denied_mask="w::" name="/data/mysql/ibdata1" pid=7711 profile="/usr/sbin/mysqld" namespace="default"
Thì không đầy đủ là gì?
dòng datadir trong file my.cnf đó là trước khi chuyển. Sau khi sửa datadir
Code:
[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
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr
datadir = /data/mysql
tmpdir = /tmp
language = /usr/share/mysql/english
nó vẫn ko work
Bồ có chmod chown recursively (-R) không? |
|
What bringing us together is stronger than what pulling us apart. |
|
 |
 |
[Question] Re: howto change mysql datadir |
05/05/2008 23:22:53 (+0700) | #8 | 129015 |
3do
Member
|
0 |
|
|
Joined: 19/04/2008 21:57:09
Messages: 24
Offline
|
|
conmale wrote:
Bồ có chmod chown recursively (-R) không?
có
Code:
$ls -la /data
drwxrwxrwx 3 mysql mysql 4096 2008-05-04 22:16 mysql
drwx------ 4 pliersn pliersn 4096 2008-04-26 17:37 .Trash-1000
drwx------ 2 pliersn pliersn 8192 2008-04-12 16:27 .Trash-pliersn
drwx------ 2 root root 4096 2007-03-05 10:10 .Trash-root
|
|
|
[Question] Re: howto change mysql datadir |
05/05/2008 23:27:03 (+0700) | #9 | 129017 |
![[Avatar] [Avatar]](/hvaonline/images/avatar/089f41810321eefc3f4eef5d4a388e42.png)
|
conmale
Administrator
|
Joined: 07/05/2004 23:43:15
Messages: 9353
Location: down under
Offline
|
|
3do wrote:
conmale wrote:
Bồ có chmod chown recursively (-R) không?
có
Code:
$ls -la /data
drwxrwxrwx 3 mysql mysql 4096 2008-05-04 22:16 mysql
drwx------ 4 pliersn pliersn 4096 2008-04-26 17:37 .Trash-1000
drwx------ 2 pliersn pliersn 8192 2008-04-12 16:27 .Trash-pliersn
drwx------ 2 root root 4096 2007-03-05 10:10 .Trash-root
Thử ls -la /data/mysql/ xem? |
|
What bringing us together is stronger than what pulling us apart. |
|
[Question] Re: howto change mysql datadir |
05/05/2008 23:48:34 (+0700) | #10 | 129023 |
3do
Member
|
0 |
|
|
Joined: 19/04/2008 21:57:09
Messages: 24
Offline
|
|
conmale wrote:
Thử ls -la /data/mysql/ xem?
Code:
$ ls /data/mysql -la
total 12
drwxrwxrwx 3 mysql mysql 4096 2008-05-04 22:16 .
drwxrwxr-x 20 root pliersn 4096 2008-04-30 21:22 ..
drwxrwxrwx 2 mysql mysql 4096 2008-05-04 22:16 get
$ ls /data/mysql/get -la
total 6744
drwxrwxrwx 2 mysql mysql 4096 2008-05-04 22:16 .
drwxrwxrwx 3 mysql mysql 4096 2008-05-04 22:16 ..
-rwxrwxrwx 1 mysql mysql 8712 2008-05-04 22:16 xxx.frm
-rwxrwxrwx 1 mysql mysql 1433384 2008-05-04 22:16 xxx.MYD
-rwxrwxrwx 1 mysql mysql 1248256 2008-05-04 22:16 xxx.MYI
-rwxrwxrwx 1 mysql mysql 61 2008-05-04 22:16 db.opt
-rwxrwxrwx 1 mysql mysql 9006 2008-05-04 22:16 xxx.frm
-rwxrwxrwx 1 mysql mysql 2818732 2008-05-04 22:16 xxx.MYD
-rwxrwxrwx 1 mysql mysql 354304 2008-05-04 22:16 xxx.MYI
-rwxrwxrwx 1 mysql mysql 8618 2008-05-04 22:16 xxx.frm
-rwxrwxrwx 1 mysql mysql 400 2008-05-04 22:16 xxx.MYD
-rwxrwxrwx 1 mysql mysql 2048 2008-05-04 22:16 xxx.MYI
-rwxrwxrwx 1 mysql mysql 13042 2008-05-04 22:16 xxx.frm
-rwxrwxrwx 1 mysql mysql 3180 2008-05-04 22:16 xxx.MYD
-rwxrwxrwx 1 mysql mysql 2048 2008-05-04 22:16 xxx.MYI
-rwxrwxrwx 1 mysql mysql 8678 2008-05-04 22:16 xxx.frm
-rwxrwxrwx 1 mysql mysql 679892 2008-05-04 22:16 xxx.MYD
-rwxrwxrwx 1 mysql mysql 244736 2008-05-04 22:16 xxx.MYI
|
|
|
 |
 |
[Question] Re: howto change mysql datadir |
05/05/2008 23:55:52 (+0700) | #11 | 129025 |
![[Avatar] [Avatar]](/hvaonline/images/avatar/089f41810321eefc3f4eef5d4a388e42.png)
|
conmale
Administrator
|
Joined: 07/05/2004 23:43:15
Messages: 9353
Location: down under
Offline
|
|
3do wrote:
conmale wrote:
Thử ls -la /data/mysql/ xem?
Code:
$ ls /data/mysql -la
total 12
drwxrwxrwx 3 mysql mysql 4096 2008-05-04 22:16 .
drwxrwxr-x 20 root pliersn 4096 2008-04-30 21:22 ..
drwxrwxrwx 2 mysql mysql 4096 2008-05-04 22:16 get
$ ls /data/mysql/get -la
total 6744
drwxrwxrwx 2 mysql mysql 4096 2008-05-04 22:16 .
drwxrwxrwx 3 mysql mysql 4096 2008-05-04 22:16 ..
-rwxrwxrwx 1 mysql mysql 8712 2008-05-04 22:16 xxx.frm
-rwxrwxrwx 1 mysql mysql 1433384 2008-05-04 22:16 xxx.MYD
-rwxrwxrwx 1 mysql mysql 1248256 2008-05-04 22:16 xxx.MYI
-rwxrwxrwx 1 mysql mysql 61 2008-05-04 22:16 db.opt
-rwxrwxrwx 1 mysql mysql 9006 2008-05-04 22:16 xxx.frm
-rwxrwxrwx 1 mysql mysql 2818732 2008-05-04 22:16 xxx.MYD
-rwxrwxrwx 1 mysql mysql 354304 2008-05-04 22:16 xxx.MYI
-rwxrwxrwx 1 mysql mysql 8618 2008-05-04 22:16 xxx.frm
-rwxrwxrwx 1 mysql mysql 400 2008-05-04 22:16 xxx.MYD
-rwxrwxrwx 1 mysql mysql 2048 2008-05-04 22:16 xxx.MYI
-rwxrwxrwx 1 mysql mysql 13042 2008-05-04 22:16 xxx.frm
-rwxrwxrwx 1 mysql mysql 3180 2008-05-04 22:16 xxx.MYD
-rwxrwxrwx 1 mysql mysql 2048 2008-05-04 22:16 xxx.MYI
-rwxrwxrwx 1 mysql mysql 8678 2008-05-04 22:16 xxx.frm
-rwxrwxrwx 1 mysql mysql 679892 2008-05-04 22:16 xxx.MYD
-rwxrwxrwx 1 mysql mysql 244736 2008-05-04 22:16 xxx.MYI
Mẹ ơi.... chắc bồ chmod 777 phải không . Kiểu này hèn chi cứ dăm ba bữa là có một cái "anh ơi, em bị hack"
Đổi lại: chmod -R go-rwx /data đi.
Và kiểm tra xem có đúng account mysql đang dùng để start mysql hay không. |
|
What bringing us together is stronger than what pulling us apart. |
|
 |
 |
[Question] Re: howto change mysql datadir |
06/05/2008 00:18:25 (+0700) | #12 | 129035 |
nbthanh
HVA Friend
|
Joined: 21/12/2001 14:51:51
Messages: 429
Offline
|
|
Theo log thì lỗi chỉ xảy ra với thằng InnoDB
--> lúc chuyển data dir, ngay trước khi start lại server bạn có chạy cái init db chưa thế? |
|
|
[Question] Re: howto change mysql datadir |
06/05/2008 00:30:03 (+0700) | #13 | 129038 |
3do
Member
|
0 |
|
|
Joined: 19/04/2008 21:57:09
Messages: 24
Offline
|
|
conmale wrote:
Mẹ ơi.... chắc bồ chmod 777 phải không . Kiểu này hèn chi cứ dăm ba bữa là có một cái "anh ơi, em bị hack"
Đổi lại: chmod -R go-rwx /data đi.
Và kiểm tra xem có đúng account mysql đang dùng để start mysql hay không.
chmod 777 chỉ là để cố tìm cách giải quyết vấn đề permisson thôi anh.
mysql được start bằng lệnh
Code:
$sudo /etc/init.d/mysql start
và vẫn chạy bình thường khi chưa đổi datadir. Nội dung của /etc/init.d/mysql
Code:
#!/bin/bash
#
### BEGIN INIT INFO
# Provides: mysql
# Required-Start: $remote_fs $syslog mysql-ndb
# Required-Stop: $remote_fs $syslog mysql-ndb
# Should-Start: $network $named $time
# Should-Stop: $network $named $time
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start and stop the mysql database server daemon
# Description: Controls the main MySQL database server daemon "mysqld"
# and its wrapper script "mysqld_safe".
### END INIT INFO
#
set -e
set -u
${DEBIAN_SCRIPT_DEBUG:+ set -v -x}
test -x /usr/sbin/mysqld || exit 0
. /lib/lsb/init-functions
SELF=$(cd $(dirname $0); pwd -P)/$(basename $0)
CONF=/etc/mysql/my.cnf
MYADMIN="/usr/bin/mysqladmin --defaults-file=/etc/mysql/debian.cnf"
# priority can be overriden and "-s" adds output to stderr
ERR_LOGGER="logger -p daemon.err -t /etc/init.d/mysql -i"
# Safeguard (relative paths, core dumps..)
cd /
umask 077
# mysqladmin likes to read /root/.my.cnf. This is usually not what I want
# as many admins e.g. only store a password without a username there and
# so break my scripts.
export HOME=/etc/mysql/
## Fetch a particular option from mysql's invocation.
#
# Usage: void mysqld_get_param option
mysqld_get_param() {
/usr/sbin/mysqld --print-defaults \
| tr " " "\n" \
| grep -- "--$1" \
| tail -n 1 \
| cut -d= -f2
}
## Do some sanity checks before even trying to start mysqld.
sanity_checks() {
# check for config file
if [ ! -r /etc/mysql/my.cnf ]; then
log_warning_msg "$0: WARNING: /etc/mysql/my.cnf cannot be read. See README.Debian.gz"
echo "WARNING: /etc/mysql/my.cnf cannot be read. See README.Debian.gz" | $ERR_LOGGER
fi
# check for diskspace shortage
datadir=`mysqld_get_param datadir`
if LC_ALL=C BLOCKSIZE= df --portability $datadir/. | tail -n 1 | awk '{ exit ($4>4096) }'; then
log_failure_msg "$0: ERROR: The partition with $datadir is too full!"
echo "ERROR: The partition with $datadir is too full!" | $ERR_LOGGER
exit 1
fi
}
## Checks if there is a server running and if so if it is accessible.
#
# check_alive insists on a pingable server
# check_dead also fails if there is a lost mysqld in the process list
#
# Usage: boolean mysqld_status [check_alive|check_dead] [warn|nowarn]
mysqld_status () {
ping_output=`$MYADMIN ping 2>&1`; ping_alive=$(( ! $? ))
ps_alive=0
pidfile=`mysqld_get_param pid-file`
if [ -f "$pidfile" ] && ps `cat $pidfile` >/dev/null 2>&1; then ps_alive=1; fi
if [ "$1" = "check_alive" -a $ping_alive = 1 ] ||
[ "$1" = "check_dead" -a $ping_alive = 0 -a $ps_alive = 0 ]; then
return 0 # EXIT_SUCCESS
else
if [ "$2" = "warn" ]; then
echo -e "$ps_alive processes alive and '$MYADMIN ping' resulted in\n$ping_output\n" | $ERR_LOGGER -p daemon.debug
fi
return 1 # EXIT_FAILURE
fi
}
#
# main()
#
case "${1:-''}" in
'start')
sanity_checks;
# Start daemon
log_daemon_msg "Starting MySQL database server" "mysqld"
if mysqld_status check_alive nowarn; then
log_progress_msg "already running"
log_end_msg 0
else
/usr/bin/mysqld_safe > /dev/null 2>&1 &
# 6s was reported in #352070 to be too few when using ndbcluster
for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14; do
sleep 1
if mysqld_status check_alive nowarn ; then break; fi
log_progress_msg "."
done
if mysqld_status check_alive warn; then
log_end_msg 0
# Now start mysqlcheck or whatever the admin wants.
output=$(/etc/mysql/debian-start)
[ -n "$output" ] && log_action_msg "$output"
else
log_end_msg 1
log_failure_msg "Please take a look at the syslog"
fi
fi
# Some warnings
if $MYADMIN variables | egrep -q have_bdb.*YES; then
echo "BerkeleyDB is obsolete, see /usr/share/doc/mysql-server-5.0/README.Debian.gz" | $ERR_LOGGER -p daemon.info
fi
if [ -f /etc/mysql/debian-log-rotate.conf ]; then
echo "/etc/mysql/debian-log-rotate.conf is obsolete, see /usr/share/doc/mysql-server-5.0/NEWS.Debian.gz" | $ERR_LOGGER -p daemon.info
fi
;;
'stop')
# * As a passwordless mysqladmin (e.g. via ~/.my.cnf) must be possible
# at least for cron, we can rely on it here, too. (although we have
# to specify it explicit as e.g. sudo environments points to the normal
# users home and not /root)
log_daemon_msg "Stopping MySQL database server" "mysqld"
if ! mysqld_status check_dead nowarn; then
set +e
shutdown_out=`$MYADMIN shutdown 2>&1`; r=$?
set -e
if [ "$r" -ne 0 ]; then
log_end_msg 1
[ "$VERBOSE" != "no" ] && log_failure_msg "Error: $shutdown_out"
log_daemon_msg "Killing MySQL database server by signal" "mysqld"
killall -15 mysqld
server_down=
for i in 1 2 3 4 5 6 7 8 9 10; do
sleep 1
if mysqld_status check_dead nowarn; then server_down=1; break; fi
done
if test -z "$server_down"; then killall -9 mysqld; fi
fi
fi
if ! mysqld_status check_dead warn; then
log_end_msg 1
log_failure_msg "Please stop MySQL manually and read /usr/share/doc/mysql-server-5.0/README.Debian.gz!"
exit -1
else
log_end_msg 0
fi
;;
'restart')
set +e; $SELF stop; set -e
$SELF start
;;
'reload'|'force-reload')
log_daemon_msg "Reloading MySQL database server" "mysqld"
$MYADMIN reload
log_end_msg 0
;;
'status')
if mysqld_status check_alive nowarn; then
log_action_msg "$($MYADMIN version)"
else
log_action_msg "MySQL is stopped."
exit 3
fi
;;
*)
echo "Usage: $SELF start|stop|restart|reload|force-reload|status"
exit 1
;;
esac
|
|
|
 |
 |
[Question] Re: howto change mysql datadir |
06/05/2008 00:34:20 (+0700) | #14 | 129039 |
3do
Member
|
0 |
|
|
Joined: 19/04/2008 21:57:09
Messages: 24
Offline
|
|
nbthanh wrote:
Theo log thì lỗi chỉ xảy ra với thằng InnoDB
--> lúc chuyển data dir, ngay trước khi start lại server bạn có chạy cái init db chưa thế?
trong đám lệnh liên quan đến mysql không thấy có cái nào liên quan đến init db
Code:
mysql mysqld mysqlimport mysqltestmanager
mysqlaccess mysqld_multi mysql_install_db mysqltestmanagerc
mysqladmin mysqld_safe mysqlmanager mysqltestmanager-pwgen
mysqlbinlog mysqldump mysqlreport mysql_tzinfo_to_sql
mysqlbug mysqldumpslow mysql_secure_installation mysql_upgrade
mysqlcheck mysql_explain_log mysql_setpermission mysql_upgrade_shell
mysql_client_test mysql_find_rows mysqlshow mysql_waitpid
mysql_client_test_embedded mysql_fix_extensions mysql_tableinfo mysql_zap
mysql_config mysql_fix_privilege_tables mysqltest
mysql_convert_table_format mysqlhotcopy mysqltest_embedded
anh Thành có thể nói rõ hơn 1 chút đc ko? |
|
|
[Question] Re: howto change mysql datadir |
06/05/2008 00:37:47 (+0700) | #15 | 129040 |
![[Avatar] [Avatar]](/hvaonline/images/avatar/089f41810321eefc3f4eef5d4a388e42.png)
|
conmale
Administrator
|
Joined: 07/05/2004 23:43:15
Messages: 9353
Location: down under
Offline
|
|
OK. Điểm kiểm tra cuối: phiên bản mysql của nơi bồ lấy cái datadir đó là phiên bản nào? Phiên bản bồ định chạy ở đây là phiên bản nào? |
|
What bringing us together is stronger than what pulling us apart. |
|
[Question] Re: howto change mysql datadir |
06/05/2008 01:58:24 (+0700) | #16 | 129062 |
nbthanh
HVA Friend
|
Joined: 21/12/2001 14:51:51
Messages: 429
Offline
|
|
3do wrote:
nbthanh wrote:
Theo log thì lỗi chỉ xảy ra với thằng InnoDB
--> lúc chuyển data dir, ngay trước khi start lại server bạn có chạy cái init db chưa thế?
trong đám lệnh liên quan đến mysql không thấy có cái nào liên quan đến init db
Code:
mysql mysqld mysqlimport mysqltestmanager
mysqlaccess mysqld_multi mysql_install_db mysqltestmanagerc
mysqladmin mysqld_safe mysqlmanager mysqltestmanager-pwgen
mysqlbinlog mysqldump mysqlreport mysql_tzinfo_to_sql
mysqlbug mysqldumpslow mysql_secure_installation mysql_upgrade
mysqlcheck mysql_explain_log mysql_setpermission mysql_upgrade_shell
mysql_client_test mysql_find_rows mysqlshow mysql_waitpid
mysql_client_test_embedded mysql_fix_extensions mysql_tableinfo mysql_zap
mysql_config mysql_fix_privilege_tables mysqltest
mysql_convert_table_format mysqlhotcopy mysqltest_embedded
anh Thành có thể nói rõ hơn 1 chút đc ko?
Trong tài liệu install MySQL, http://dev.mysql.com/doc/refman/5.0/en/installing-binary.html, có 1 câu lệnh là:
shell> scripts/mysql_install_db --user=mysql |
|
|
 |
 |
[Question] Re: howto change mysql datadir |
06/05/2008 02:30:37 (+0700) | #17 | 129065 |
3do
Member
|
0 |
|
|
Joined: 19/04/2008 21:57:09
Messages: 24
Offline
|
|
conmale wrote:
OK. Điểm kiểm tra cuối: phiên bản mysql của nơi bồ lấy cái datadir đó là phiên bản nào? Phiên bản bồ định chạy ở đây là phiên bản nào?
Việc thay đổi datadir là do phân vùng chứa /var/lib/mysql sắp đầy nên cần phải chuyển đổi qua 1 thư mục trên 1 phân vùng khác.
Phiên bản của mysql: 5.0.51a-3ubuntu5 |
|
|
[Question] Re: howto change mysql datadir |
06/05/2008 02:41:07 (+0700) | #18 | 129068 |
3do
Member
|
0 |
|
|
Joined: 19/04/2008 21:57:09
Messages: 24
Offline
|
|
nbthanh wrote:
Trong tài liệu install MySQL, http://dev.mysql.com/doc/refman/5.0/en/installing-binary.html, có 1 câu lệnh là:
shell> scripts/mysql_install_db --user=mysql
tại /data/mysql
Code:
$ sudo mysql_install_db --user=mysql
Installing MySQL system tables...
080505 13:39:59 [Warning] Can't create test file /data/mysql/pliersn-laptop.lower-test
080505 13:39:59 [Warning] Can't create test file /data/mysql/pliersn-laptop.lower-test
ERROR: 1005 Can't create table 'db' (errno: 13)
080505 13:39:59 [ERROR] Aborting
080505 13:39:59 [Note] /usr/sbin/mysqld: Shutdown complete
Installation of system tables failed!
Examine the logs in /data/mysql for more information.
You can try to start the mysqld daemon with:
/usr/sbin/mysqld --skip-grant &
and use the command line tool
/usr/bin/mysql to connect to the mysql
database and look at the grant tables:
shell> /usr/bin/mysql -u root mysql
mysql> show tables
Try 'mysqld --help' if you have problems with paths. Using --log
gives you a log in /data/mysql that may be helpful.
The latest information about MySQL is available on the web at
http://www.mysql.com
Please consult the MySQL manual section: 'Problems running mysql_install_db',
and the manual section that describes problems on your OS.
Another information source is the MySQL email archive.
Please check all of the above before mailing us!
And if you do mail us, you MUST use the /usr/bin/mysqlbug script!
|
|
|
 |
 |
[Question] Re: howto change mysql datadir |
06/05/2008 03:59:06 (+0700) | #19 | 129087 |
nbthanh
HVA Friend
|
Joined: 21/12/2001 14:51:51
Messages: 429
Offline
|
|
Như vậy thì ngay bước init db là đã có lỗi rồi
1. Lúc bạn init thư mục đó đang empty hay có data rồi?
2. Lúc bạn init, bạn đang login vào account nào và chown/chmod của folder đó ra sao?
P/S: Cách cuối cùng:
Dump toàn bộ dữ liệu ra
Cài lại MySQL lên thư mục mới
Import dữ liệu ngược lại
Cách này thì chắc chắn là được đó  |
|
|
[Question] Re: howto change mysql datadir |
06/05/2008 04:22:58 (+0700) | #20 | 129090 |
3do
Member
|
0 |
|
|
Joined: 19/04/2008 21:57:09
Messages: 24
Offline
|
|
nbthanh wrote:
Như vậy thì ngay bước init db là đã có lỗi rồi
1. Lúc bạn init thư mục đó đang empty hay có data rồi?
thử cả 2 trường hợp, 1 trường hợp đã có các file bên trong (được chép từ /vả/lib/mysql) và 1 trường hợp không có file nào bên trong
2. Lúc bạn init, bạn đang login vào account nào và chown/chmod của folder đó ra sao?
lệnh mysql_install_db chạy với quyền root.
chown mysql:mysql -R /data/mysql
P/S: Cách cuối cùng:
Dump toàn bộ dữ liệu ra
Cài lại MySQL lên thư mục mới
Import dữ liệu ngược lại
Cách này thì chắc chắn là được đó
không hiểu y' anh về việc cài mysql lên thư mục mới? (y' anh là cài từ tar.gz?) Hiện tại thì mysql là gói build sẵn (.deb).
Database thật sự trên server của em khá bự (trên 8 triệu record) và mỗi lần restore từ .sql mất khoảng nửa ngày nên cách này không ổn cho lắm (hiện đang test việc change datadir trên laptop) |
|
|
[Question] Re: howto change mysql datadir |
06/05/2008 05:32:05 (+0700) | #21 | 129099 |
nbthanh
HVA Friend
|
Joined: 21/12/2001 14:51:51
Messages: 429
Offline
|
|
Tôi đã kiểm tra kỹ MySQL Manual thì lỗi đó 100% là do permission, tham khảo: http://dev.mysql.com/doc/refman/6.0/en/operating-system-error-codes.html
#13 (EACCES)
Permission denied
Tuy nhiên, có 1 số trường hợp hiếm gặp là disk lỗi hoặc full nó cũng trả về lỗi permission. Vậy bạn kiểm tra lại:
- Permission của thư mục /data và /data/mysql, Bạn tuy chạy với account root nhưng chú ý là có tham số --user=mysql
- Kiểm tra kỹ lại dung lượng của partition chứa /data/mysql, innodb ngay lúc đầu tiên nó sẽ tạo sẵn 1 số file, có thể chiếm 10-20Mb, khác với MyIASM.
- Kiểm tra kỹ dung lượng của partition chứa thư mục /tmp, có thể lúc đầu nó tạo file trong temp rồi mới chép qua bên kia
...nói chung....là kiểm tra kỹ kỹ kỹ mọi thứ  |
|
|
[Question] Re: howto change mysql datadir |
06/05/2008 06:03:46 (+0700) | #22 | 129108 |
3do
Member
|
0 |
|
|
Joined: 19/04/2008 21:57:09
Messages: 24
Offline
|
|
nbthanh wrote:
Tôi đã kiểm tra kỹ MySQL Manual thì lỗi đó 100% là do permission, tham khảo: http://dev.mysql.com/doc/refman/6.0/en/operating-system-error-codes.html
#13 (EACCES)
Permission denied
Tuy nhiên, có 1 số trường hợp hiếm gặp là disk lỗi hoặc full nó cũng trả về lỗi permission. Vậy bạn kiểm tra lại:
- Permission của thư mục /data và /data/mysql, Bạn tuy chạy với account root nhưng chú ý là có tham số --user=mysql
- Kiểm tra kỹ lại dung lượng của partition chứa /data/mysql, innodb ngay lúc đầu tiên nó sẽ tạo sẵn 1 số file, có thể chiếm 10-20Mb, khác với MyIASM.
- Kiểm tra kỹ dung lượng của partition chứa thư mục /tmp, có thể lúc đầu nó tạo file trong temp rồi mới chép qua bên kia
...nói chung....là kiểm tra kỹ kỹ kỹ mọi thứ
Kích thước phân vùng /data
Code:
Filesystem Size Used Avail Use% Mounted on
/dev/sda9 25G 9.1G 15G 40% /
varrun 728M 116K 728M 1% /var/run
varlock 728M 0 728M 0% /var/lock
udev 728M 68K 728M 1% /dev
devshm 728M 36K 728M 1% /dev/shm
lrm 728M 38M 690M 6% /lib/modules/2.6.24-16-generic/volatile
/dev/sda5 99M 24M 71M 26% /boot
/dev/sda8 9.0G 7.1G 1.5G 83% /data
thư mục /data cũng có quyền 777
/tmp nằm trong phân vùng /
việc change datadir này lúc trước đã thực hiện thành công dễ dàng trên 1 máy chạy centos, nhưng lần này ko hiểu taị sao nó ko work |
|
|
 |
 |
[Question] Re: howto change mysql datadir |
06/05/2008 21:13:25 (+0700) | #23 | 129203 |
3do
Member
|
0 |
|
|
Joined: 19/04/2008 21:57:09
Messages: 24
Offline
|
|
đã thử nghiệm trên server chạy CentOS, mọi thứ đều ok
lí do là bản mysql trên hardy có vấn đề
Cảm ơn mọi người đã giúp đỡ |
|
|
Users currently in here |
2 Anonymous
|
|
Powered by JForum - Extended by HVAOnline
hvaonline.net | hvaforum.net | hvazone.net | hvanews.net | vnhacker.org
1999 - 2013 ©
v2012|0504|218|
|
|