开通ECS时选择了Ubuntu的Java环境镜像,其中自带了MySQL,但MySQL的数据目录在/var/lib/mysql下。
因为我已购买数据盘,并挂载为/data,想把MySQL的数据目录移动到/data/mysql下,始终不成功。求解答!
我做的步骤:
1、关闭MySQL:service mysql stop
2、复制数据目录:cp -ria /var/lib/mysql /data/mysql,也试过mv /var/lib/mysql/data/mysql
3、修改/etc/mysql/my.cnf文件中的data_dir配置项
4、启动MySQL结果:始终报如下错误:
140518 20:44:10 [Warning] Using unique option prefix key_buffer instead of key_buffer_size is deprecated and will be removed in a future release. Please use the full name instead.
140518 20:44:10 [Warning] Can't create test file /data/mysql/AY140514205840355de9Z.lower-test
140518 20:44:10 [Warning] Can't create test file /data/mysql/AY140514205840355de9Z.lower-test
140518 20:44:10 [Warning] Using unique option prefix myisam-recover instead of myisam-recover-options is deprecated and will be removed in a future release. Please use the full name instead.
140518 20:44:10 [Note] Plugin 'FEDERATED' is disabled.
mysqld: Can't find file: './mysql/plugin.frm' (errno: 13)
140518 20:44:10 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
140518 20:44:10 InnoDB: The InnoDB memory heap is disabled
140518 20:44:10 InnoDB: Mutexes and rw_locks use GCC atomic builtins
140518 20:44:10 InnoDB: Compressed tables use zlib 1.2.3.4
140518 20:44:10 InnoDB: Initializing buffer pool, size = 128.0M
140518 20:44:10 InnoDB: Completed initialization of buffer pool
140518 20:44:10 InnoDB: Operating system error number 13 in a file operation.
InnoDB: The error means mysqld does not have the access rights to
InnoDB: the directory.
InnoDB: File name ./ibdata1
InnoDB: File operation call: 'open'.
InnoDB: Cannot continue operation.
5、核对目录权限应该没有问题
:~# ls -l /data/mysql
total 28736
-rw-r--r-- 1 mysql mysql 0 Apr 24 20:11 debian-5.5.flag
-rw-rw---- 1 mysql mysql 18874368 May 16 15:05 ibdata1
-rw-rw---- 1 mysql mysql 5242880 May 16 15:05 ib_logfile0
-rw-rw---- 1 mysql mysql 5242880 Apr 15 12:26 ib_logfile1
drwx------ 2 mysql mysql 4096 Apr 24 20:11 mysql
-rw-rw---- 1 mysql mysql 6 Apr 24 20:11 mysql_upgrade_info
drwx------ 2 mysql mysql 4096 Apr 24 20:11 performance_schema
drwx------ 2 mysql mysql 4096 Apr 15 12:26 test
:~# ls -l /var/lib/mysql
total 28688
-rw-r--r-- 1 mysql mysql 0 Apr 24 20:11 debian-5.5.flag
-rw-rw---- 1 mysql mysql 18874368 May 16 16:43 ibdata1
-rw-rw---- 1 mysql mysql 5242880 May 16 16:43 ib_logfile0
-rw-rw---- 1 mysql mysql 5242880 Apr 15 12:26 ib_logfile1
drwx------ 2 mysql mysql 4096 Apr 24 20:11 mysql
-rw-rw---- 1 mysql mysql 6 Apr 24 20:11 mysql_upgrade_info
drwx------ 2 mysql mysql 4096 Apr 24 20:11 performance_schema
drwx------ 2 mysql mysql 4096 Apr 15 12:26 test
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。