发布网友 发布时间:2022-04-21 08:14
共2个回答
懂视网 时间:2022-04-30 09:35
http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm rpm -ivh mysql-community-release-el7-5.noarch.rpm yum install mysql-community-server serivce mysqld start此时查看数据目录,是/var/lib/mysql
2. 修改配置
2.1 修改安全限制
vim /etc/selinux/config
将内容修改如下:
# SELINUX=enforcing SELINUX=permissive
2.2 修改数据库配置
首先停用MySQL。
1. 复制数据目录
cp -R /var/lib/mysql /data/ chown -R mysql:mysql /data/mysql
2. 修改配置
备份/etc/my.cnf
cp /etc/my.cnf /etc/my.cnf-bk
修改/etc/my.cnf为
[mysqld_safe] log-error=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid [mysqld] log_error = /var/log/mysql-error.log user = mysql datadir = /data/mysql socket = /data/mysql/mysql.sock [mysql] socket = /data/mysql/mysql.sock user = mysql
3. 验证
重启mysql服务,mysql客户端登录,查看datadir
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/ | | ignore_db_dirs | | | innodb_data_home_dir | | | innodb_log_group_home_dir | ./ | | innodb_max_dirty_pages_pct | 75 | | innodb_max_dirty_pages_pct_lwm | 0 | | innodb_undo_directory | . | | lc_messages_dir | /usr/share/mysql/ | | plugin_dir | /usr/lib64/mysql/plugin/ | | slave_load_tmpdir | /tmp | | tmpdir | /tmp | +-----------------------------------------+----------------------------+ 14 rows in set (0.03 sec)
配置成功!!!
修改MySQL的数据目录
标签:
热心网友 时间:2022-04-30 06:43
具体操作: