Home >Database >Mysql Tutorial > mysql移动数据存放目录及问题

mysql移动数据存放目录及问题

WBOY
WBOYOriginal
2016-06-07 17:37:021033browse

我计划更换数据库的存放目录,下面是我的操作步骤1:首先创建新的数据存放路径并授予权限[root@pacteralinuxmntsdc2formysql]#df-hFilesystemSizeUsedAvailUse%M

我计划更换数据库的存放目录,下面是我的操作步骤

1:首先创建新的数据存放路径并授予权限

[root@pacteralinux mntsdc2formysql]# df -h Filesystem Size Used Avail Use% Mounted on /dev/sda1 29G 20G 7.5G 73% / tmpfs 776M 0 776M 0% /dev/shm /dev/sdb1 69G 4.0G 62G 6% /mnt/resource /dev/sdc1 362G 53G 291G 16% /usr/local/Tomcat_Trans/webapps/infoSocketService/logs /dev/sdc2 131G 2.2G 122G 2% /mnt/mntsdc2formysql [root@pacteralinux mntsdc2formysql]# pwd /mnt/mntsdc2formysql [root@pacteralinux mntsdc2formysql]# mkdir mysqldata [root@pacteralinux mntsdc2formysql]# ll total 2050024 drwx------. 2 root root 16384 Dec 2 14:20 lost+found drwxr-xr-x. 2 root root 4096 Dec 26 13:29 mysqldata -rw-r--r--. 1 root root 2097152000 Dec 7 23:20 swapfile [root@pacteralinux mntsdc2formysql]# cd mysqldata/ [root@pacteralinux mysqldata]# chown mysql:mysql . [root@pacteralinux mysqldata]# cd .. [root@pacteralinux mntsdc2formysql]# ll total 2050024 drwx------. 2 root root 16384 Dec 2 14:20 lost+found drwxr-xr-x. 2 mysql mysql 4096 Dec 26 13:29 mysqldata -rw-r--r--. 1 root root 2097152000 Dec 7 23:20 swapfile [root@pacteralinux mntsdc2formysql]# chmod 755 mysqldata/ [root@pacteralinux mntsdc2formysql]# ll total 2050024 drwx------. 2 root root 16384 Dec 2 14:20 lost+found drwxr-xr-x. 2 mysql mysql 4096 Dec 26 13:29 mysqldata -rw-r--r--. 1 root root 2097152000 Dec 7 23:20 swapfile

2:停止mysql

[root@pacteralinux mntsdc2formysql]# ps -ef|grep mysql root 7451 7425 0 13:28 pts/1 00:00:00 grep mysql root 56138 1 0 Dec24 ? 00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/mnt/resource/mysqldate --pid-file=/mnt/resource/mysqldate/pacteralinux.pid mysql 56391 56138 0 Dec24 ? 00:00:44 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/mnt/resource/mysqldate --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/mnt/resource/mysqldate/pacteralinux.err --pid-file=/mnt/resource/mysqldate/pacteralinux.pid --socket=/mnt/resource/mysqldate/mysql.sock --port=3306 [root@pacteralinux ~]# service mysqld stop Shutting down MySQL..[ OK ] [root@pacteralinux ~]# service mysqld stop Shutting down MySQL..[ OK ] [root@pacteralinux ~]# ps -ef|grep mysql root 7505 7376 0 13:32 pts/0 00:00:00 grep mysql

3:移动目录

我现在数据库的存放路径为

[root@pacteralinux ~]# cd /mnt/resource/mysqldate [root@pacteralinux mysqldate]# ll total 176676 -rw-rw----. 1 mysql mysql 56 Nov 25 17:17 auto.cnf -rw-rw----. 1 mysql mysql 79691776 Dec 26 13:32 ibdata1 -rw-rw----. 1 mysql mysql 50331648 Dec 26 13:32 ib_logfile0 -rw-rw----. 1 mysql mysql 50331648 Nov 26 13:39 ib_logfile1 drwx------. 2 mysql mysql 4096 Nov 26 13:41 mysql drwx------. 2 mysql mysql 20480 Nov 26 17:00 mysqldb -rw-rw----. 1 mysql root 514836 Dec 26 13:32 pacteralinux.err drwx------. 2 mysql mysql 4096 Nov 26 13:41 performance_schema drwx------. 2 mysql mysql 4096 Nov 26 13:41 test drwx------. 2 mysql mysql 4096 Dec 9 16:49 weixindemo

移动

[root@pacteralinux resource]# mv mysqldate/ /mnt/mntsdc2formysql/mysqldata/ [root@pacteralinux resource]# ll total 24 drwx------. 2 root root 16384 Nov 20 13:57 lost+found drwxr-xr-x. 2 root root 4096 Dec 2 15:02 mysqldataper drwxr-xr-x. 2 root root 4096 Dec 2 15:02 sdc3mnt [root@pacteralinux resource]# pwd /mnt/resource [root@pacteralinux resource]# cd /mnt/mntsdc2formysql/ [root@pacteralinux mntsdc2formysql]# ll total 2050024 drwx------. 2 root root 16384 Dec 2 14:20 lost+found drwxr-xr-x. 3 mysql mysql 4096 Dec 26 13:42 mysqldata -rw-r--r--. 1 root root 2097152000 Dec 7 23:20 swapfile [root@pacteralinux mntsdc2formysql]# cd mysqldata/ [root@pacteralinux mysqldata]# ll total 4 drwxr-xr-x. 7 mysql mysql 4096 Dec 26 13:32 mysqldate [root@pacteralinux mysqldata]# cd mysqldate/ [root@pacteralinux mysqldate]# ll total 176860 -rw-rw----. 1 mysql mysql 56 Nov 25 17:17 auto.cnf -rw-rw----. 1 mysql mysql 79691776 Dec 26 13:32 ibdata1 -rw-rw----. 1 mysql mysql 50331648 Dec 26 13:32 ib_logfile0 -rw-rw----. 1 mysql mysql 50331648 Nov 26 13:39 ib_logfile1 drwx------. 2 mysql mysql 4096 Nov 26 13:41 mysql drwx------. 2 mysql mysql 20480 Nov 26 17:00 mysqldb -rw-rw----. 1 mysql root 514836 Dec 26 13:32 pacteralinux.err drwx------. 2 mysql mysql 4096 Nov 26 13:41 performance_schema drwx------. 2 mysql mysql 4096 Nov 26 13:41 test drwx------. 2 mysql mysql 4096 Dec 9 16:49 weixindemo [root@pacteralinux mysqldate]# mv * ../ [root@pacteralinux mysqldate]# ll total 0 [root@pacteralinux mysqldate]# cd .. [root@pacteralinux mysqldata]# ll total 176864 -rw-rw----. 1 mysql mysql 56 Nov 25 17:17 auto.cnf -rw-rw----. 1 mysql mysql 79691776 Dec 26 13:32 ibdata1 -rw-rw----. 1 mysql mysql 50331648 Dec 26 13:32 ib_logfile0 -rw-rw----. 1 mysql mysql 50331648 Nov 26 13:39 ib_logfile1 drwx------. 2 mysql mysql 4096 Nov 26 13:41 mysql drwxr-xr-x. 2 mysql mysql 4096 Dec 26 13:48 mysqldate drwx------. 2 mysql mysql 20480 Nov 26 17:00 mysqldb -rw-rw----. 1 mysql root 514836 Dec 26 13:32 pacteralinux.err drwx------. 2 mysql mysql 4096 Nov 26 13:41 performance_schema drwx------. 2 mysql mysql 4096 Nov 26 13:41 test drwx------. 2 mysql mysql 4096 Dec 9 16:49 weixindemo [root@pacteralinux mysqldata]# rm -rf mysqldate/ [root@pacteralinux mysqldata]# ll total 176860 -rw-rw----. 1 mysql mysql 56 Nov 25 17:17 auto.cnf -rw-rw----. 1 mysql mysql 79691776 Dec 26 13:32 ibdata1 -rw-rw----. 1 mysql mysql 50331648 Dec 26 13:32 ib_logfile0 -rw-rw----. 1 mysql mysql 50331648 Nov 26 13:39 ib_logfile1 drwx------. 2 mysql mysql 4096 Nov 26 13:41 mysql drwx------. 2 mysql mysql 20480 Nov 26 17:00 mysqldb -rw-rw----. 1 mysql root 514836 Dec 26 13:32 pacteralinux.err drwx------. 2 mysql mysql 4096 Nov 26 13:41 performance_schema drwx------. 2 mysql mysql 4096 Nov 26 13:41 test drwx------. 2 mysql mysql 4096 Dec 9 16:49 weixindemo [root@pacteralinux mysqldata]#
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article: MongoDB主从复制Next article: SQL2008R2 清空日志