解决修改mysql的data_dir所引发的错误分分快三全天

作者:分分快三全天计划网站

开掘错误音讯如下:
[Warning] Can't create test file /mnt/mysql/iZwz9c03srb2lq9l374if5Z.lower-test

始建 迁移文件夹

cd /mnt
mkdir lib
cd lib && mkdir mysqldata
数码存放在 /mnt/lib/mysqldata

改过所属客商 和所属顾客组为 msyql

sudo chown -vR mysql:mysql /mnt/lib/mysqldata

校订权限

sudo chmod -vR 700 /mnt/lib/mysqldata

vi /etc/apparmor.d/usr.sbin.mysqld

改善步骤

可是却开采运营战败,于是再去寻访mysql的谬误日志:

vim /etc/mysql/mysql.conf.d/mysqld.cnf

将 [mysqld] 组下的 datadir改为:
datadir = /mnt/lib/mysqldata

sudo vim /etc/apparmor.d/usr.sbin.mysqld

找到此中的

/var/lib/mysql/ r,
/var/lib/mysql/** rwk,

两行权限注明,可以在前头加上#好注释掉。然后相比格式,参与新路径的权杖评释:
/mnt/lib/mysqldata/ r,
/mnt/lib/mysqldata/** rwk

重启服务
配备文件改革成功后就足以重启数据库,重启数据库早前要求先重新载入apparmor配置文件,使用上面视若等闲重新载入:

sudo /etc/init.d/apparmor restart

sudo /etc/init.d/mysql start

重启的时候
Starting mysql (via systemctl): mysql.serviceJob for mysql.service failed because the control process exited with error code. See "systemctl status mysql.service" and "journalctl -xe" for details.
failed!
root@iZm5e472vz1trxejt8m5akZ:/etc/mysql# systemctl status mysql.service
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: active since Sat 2018-06-23 00:55:37 CST; 25s ago
Process: 13418 ExecStartPost=/usr/share/mysql/mysql-systemd-start post (code=exited, status=0/SUCCESS)
Process: 13408 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
Main PID: 13417
CGroup: /system.slice/mysql.service
└─13417 /usr/sbin/mysqld

. 配置文件 内容

## The MySQL database server configuration file.## You can copy this to one of:# - "/etc/mysql/my.cnf" to set global options,# - "~/.my.cnf" to set user-specific options.# # One can use all long options that the program supports.# Run program with --help to get a list of available options and with# --print-defaults to see which it would actually understand and use.## For explanations see# http://dev.mysql.com/doc/mysql/en/server-system-variables.html# This will be passed to all mysql clients# It has been reported that passwords should be enclosed with ticks/quotes# escpecially if they contain "#" chars...# Remember to edit /etc/mysql/debian.cnf when changing the socket location.# Here is entries for some specific programs# The following values assume you have at least 32M ram[mysqld_safe]socket = /var/run/mysqld/mysqld.socknice = 0[mysqld]## * Basic Settings#user = mysqlpid-file = /var/run/mysqld/mysqld.pidsocket = /var/run/mysqld/mysqld.sockport = 3306basedir = /usr# datadir = /var/lib/mysqldatadir = /mnt/lib/mysqldatatmpdir = /tmplc-messages-dir = /usr/share/mysqlskip-external-locking## Instead of skip-networking the default is now to listen only on# localhost which is more compatible and is not less secure.bind-address = 0.0.0.0## * Fine Tuning#key_buffer_size = 16Mmax_allowed_packet = 16Mthread_stack = 192Kthread_cache_size = 8# This replaces the startup script and checks MyISAM tables if needed# the first time they are touchedmyisam-recover-options = BACKUP#max_connections = 100#table_cache = 64#thread_concurrency = 10## * Query Cache Configuration#query_cache_limit = 1Mquery_cache_size = 16M## * Logging and Replication## Both location gets rotated by the cronjob.# Be aware that this log type is a performance killer.# As of 5.1 you can enable the log at runtime!#general_log_file = /var/log/mysql/mysql.log#general_log = 1## Error log - should be very few entries.#log_error = /var/log/mysql/error.log## Here you can see queries with especially long duration#log_slow_queries = /var/log/mysql/mysql-slow.log#long_query_time = 2#log-queries-not-using-indexes## The following can be used as easy to replay backup logs or for replication.# note: if you are setting up a replication slave, see README.Debian about# other settings you may need to change.#server-id = 1#log_bin = /var/log/mysql/mysql-bin.logexpire_logs_days = 10max_binlog_size = 100M#binlog_do_db = include_database_name#binlog_ignore_db = include_database_name## * InnoDB## InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/.# Read the manual for more InnoDB related options. There are many!## * Security Features## Read the manual, too, if you want chroot!# chroot = /var/lib/mysql/## For generating SSL certificates I recommend the OpenSSL GUI "tinyca".## ssl-ca=/etc/mysql/cacert.pem# ssl-cert=/etc/mysql/server-cert.pem# ssl-key=/etc/mysql/server-key.pem

坑爹啊,刚刚将mysql配置文件的datadir的/var/lib/mysql已经济体改了,不过却如故被那儿限定了,于是,将它改良为:

Ubuntu16.04 改良mysql 数据存款和储蓄目录datadir 运维战败 5C
Ubuntu16.04 校订mysql 数据存储目录datadir 运转退步,网络的种种法子都曾经尝试,可是照旧不曾运维成功请教各位大神!!!!!

# Allow data dir access
/var/lib/mysql/ r,
/var/lib/mysql/** rwk,
/mnt/mysql/ r,
/mnt/mysql/** rwk,

搬迁文件

悬停服务

sudo /etc/init.d/mysql stop

搬迁数据

cp -av /var/lib/mysql/* /mnt/lib/mysqldata

tail -f -n100 /var/log/mysql/error.log
systemctl start mysql
service apparmor restart
vi /etc/mysql/mysql.conf.d/mysqld.cnf

意识datadir=/var/lib/mysql, 那也正是数量所在目录,于是将它纠正为datadir=/mnt/mysql, 然后保存, 最后将mysql保存的数码的拷贝到/mnt下:

今天,搭建新购的Ali云ECS意况(ubuntu 16.04 LTS),须要将mysql的数目保存在新挂载的磁盘上(已挂载到/mnt下卡塔尔国,先停掉mysql服务,然后查看mysql并数据保存的岗位:

接下来再一次运转mysql服务:

保存。重启apparmor服务:

细想一下,mysql的安顿相应没难点了呀。检查一下apparmor的安排:

察觉其间犹如下配置:

systemctl start mysql
# Allow data dir access
/var/lib/mysql/ r,
/var/lib/mysql/** rwk,
cp -r /var/lib/mysql /mnt
chown -R mysql:mysql /mnt/mysql

劳务到底运维成功了。。。

自己的博客: javafan.cn

姣好拷贝后,本以为全数就绪,开启mysql服务:

本文由分分快三计划发布,转载请注明来源

关键词: 分分快三计划 Ubuntu 数据存储 目录 datadir