因是测试环境就没太在意硬盘的划分,直接将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/