Step 1: Change the address of the mysql data storage to the default path/var/lib/mysql/, and change it to/data/mysql/data.
mysql> show variables like '%dir%';+-----------------------------------------+----------------------------+| Variable_name | Value |+-----------------------------------------+----------------------------+| basedir | /usr || binlog_direct_non_transactional_updates | OFF || character_sets_dir | /usr/share/mysql/charsets/ || datadir | /var/lib/mysql/ || innodb_data_home_dir | || innodb_log_group_home_dir | ./ || innodb_max_dirty_pages_pct | 75 || lc_messages_dir | /usr/share/mysql/ || plugin_dir | /usr/lib64/mysql/plugin/ || slave_load_tmpdir | /tmp || tmpdir | /tmp |+-----------------------------------------+----------------------------+11 rows in set (0.00 sec)
2. Disable the mysql service.
service mysql stop
3. Create a directory, modify the permissions, and send the cp-related files to the target directory.
The new data storage path is/data/mysql/datamkdir-p/data/mysql/data. Change the new path permission host chown mysql: mysql/data/mysql/data copy all the original data to the new path cp-a/var/lib/mysql/*/data/mysql/data/
4. modify the configuration file
[root@stmysql1 lib]# vi /etc/rc.d/init.d/mysqlbasedir=datadir=/data/mysql/data
5. Start mysql
service mysql start
6. The modified address is as follows. The address has been modified successfully.
-bash-3.2$ mysqlWelcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 1Server version: 5.5.33 MySQL Community Server (GPL)Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql> show variables like '%dir%';+-----------------------------------------+----------------------------+| Variable_name | Value |+-----------------------------------------+----------------------------+| basedir | /usr || binlog_direct_non_transactional_updates | OFF || character_sets_dir | /usr/share/mysql/charsets/ || datadir | /data/mysql/data/ || innodb_data_home_dir | || innodb_log_group_home_dir | ./ || innodb_max_dirty_pages_pct | 75 || lc_messages_dir | /usr/share/mysql/ || plugin_dir | /usr/lib64/mysql/plugin/ || slave_load_tmpdir | /tmp || tmpdir | /tmp |+-----------------------------------------+----------------------------+11 rows in set (0.00 sec)