运行的数据库修改datadir目录



因是测试环境就没太在意硬盘的划分,直接将data放在/下了,结果悲剧发生了。最近数据增长过快啊,马上就要满了,这是往死里测试呀!!!!!!不得不将datadir重新指向一个大的磁盘了。
以前就是在/下建了一个data的目录
现在换了一个lv挂载在/data_1目录下
1.重新初始化
cd /opt/mysql/scripts/
./mysql_install_db --user=mysql --datadir=/data_1 --basedir=/opt/mysql --log-error=/log/log_err.log
Installing MySQL system tables...2015-12-23 12:25:50 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
OK
Filling help tables...2015-12-23 12:25:52 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
  /opt/mysql/bin/mysqladmin -u root password 'new-password'
  /opt/mysql/bin/mysqladmin -u root -h master password 'new-password'
Alternatively you can run:
  /opt/mysql/bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:
  cd . ; /opt/mysql/bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
  cd mysql-test ; perl mysql-test-run.pl
Please report any problems with the ./bin/mysqlbug script!
The latest information about MySQL is available on the web at

  http://www.mysql.com

Support MySQL by buying support/licenses at http://shop.mysql.com

WARNING: Found existing config file /opt/mysql/my.cnf on the system.
Because this file might be in use, it was not replaced,
but was used in bootstrap (unless you used --defaults-file)
and when you later start the server.
The new default config file was created as /opt/mysql/my-new.cnf,
please compare it with your file and take the changes you need.

WARNING: Default config file /etc/my.cnf exists on the system
This file will be read by default by the MySQL server
If you do not want to use this, either remove it, or use the
--defaults-file argument to mysqld_safe when starting the server

2.修改my.cnf
 basedir = /opt/mysql
 datadir = /data_1         //将原来的/data换为/data_1
 port = 3306
 server_id = 1
 socket = /tmp/mysql.sock

3.将/data下的所有文件都cp到/data_1下
类似于冷备份后恢复,注意权限

cp -rp /data/*  /data_1/

注:重新初始化后/data_1下后有自带的库文件,将其备份到别的地方去或直接删除就可以的哟,不然第三部的时候一直提示

4.启动数据库
./mysqld_safe --user=mysql &

检测
mysql> show variables like '%datadir%';
+---------------+----------+
| Variable_name | Value    |
+---------------+----------+
| datadir       | /data_1/ |
+---------------+----------+
1 row in set (0.00 sec)
系统
[root@master bin]# ps -ef | grep mysql
root      3749 18419  0 12:28 pts/4    00:00:00 /bin/sh ./mysqld_safe --user=mysql
mysql     4025  3749  0 12:28 pts/4    00:00:02 /opt/mysql/bin/mysqld --basedir=/opt/mysql --datadir=/data_1 --plugin-dir=/opt/mysql/lib/plugin --user=mysql --log-error=/log/log_err.log --pid-file=/data_1/master.pid --socket=/tmp/mysql.sock --port=3306



来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/26909803/viewspace-1878229/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/26909803/viewspace-1878229/

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值