这个是我记录的步骤, http://www.waylau.com/centos-7-install-mysql/
主要是做了如下操作
移动数据到数据存放目录
`/var/lib/mysql` 整个目录移到 `/home/data`,执行
mv /var/lib/mysql /home/data
这样就把 MySQL 的数据文件移动到了 `/home/data/mysql` 下
修改 `/etc/my.cnf` 文件,
[mysqld]
datadir=/home/data/mysql
socket=/home/data/mysql/mysql.sock
[mysql]
socket=/home/data/mysql/mysql.sock
切换到 MySQL 安装目录 /usr/bin,执行
chown -R mysql .
chgrp -R mysql .
而后 我再 执行 systemctl start mysqld
就没有响应了,好像死掉一样,直到 我执行 ctr+c 来取消那个命令
看了下 日志 /var/log/mysqld.log
150515 14:44:12 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
150515 14:50:21 mysqld_safe Starting mysqld daemon with databases from /home/data/mysql
2015-05-15 14:50:22 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2015-05-15 14:50:22 0 [Note] /usr/sbin/mysqld (mysqld 5.6.24) starting as process 1761 ...
2015-05-15 14:50:22 1761 [Warning] Can't create test file /home/data/mysql/localhost.lower-test
2015-05-15 14:50:22 1761 [Warning] Can't create test file /home/data/mysql/localhost.lower-test
2015-05-15 14:50:22 1761 [Warning] Buffered warning: Changed limits: max_open_files: 1024 (requested 5000)
2015-05-15 14:50:22 1761 [Warning] Buffered warning: Changed limits: table_open_cache: 431 (requested 2000)
2015-05-15 14:50:22 1761 [Note] Plugin 'FEDERATED' is disabled.
2015-05-15 14:50:22 1761 [Note] InnoDB: Using atomics to ref count buffer pool pages
2015-05-15 14:50:22 1761 [Note] InnoDB: The InnoDB memory heap is disabled
2015-05-15 14:50:22 1761 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2015-05-15 14:50:22 1761 [Note] InnoDB: Memory barrier is not used
2015-05-15 14:50:22 1761 [Note] InnoDB: Compressed tables use zlib 1.2.3
2015-05-15 14:50:22 1761 [Note] InnoDB: Using Linux native AIO
2015-05-15 14:50:22 1761 [Note] InnoDB: Not using CPU crc32 instructions
2015-05-15 14:50:22 1761 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2015-05-15 14:50:22 1761 [Note] InnoDB: Completed initialization of buffer pool
2015-05-15 14:50:23 1761 [Note] InnoDB: Highest supported file format is Barracuda.
2015-05-15 14:50:23 1761 [Note] InnoDB: 128 rollback segment(s) are active.
2015-05-15 14:50:23 1761 [Note] InnoDB: Waiting for purge to start
2015-05-15 14:50:23 1761 [Note] InnoDB: 5.6.24 started; log sequence number 1654293
2015-05-15 14:50:23 1761 [Note] Server hostname (bind-address): '*'; port: 3306
2015-05-15 14:50:23 1761 [Note] IPv6 is available.
2015-05-15 14:50:23 1761 [Note] - '::' resolves to '::';
2015-05-15 14:50:23 1761 [Note] Server socket created on IP: '::'.
2015-05-15 14:50:23 1761 [ERROR] Can't start server : Bind on unix socket: Permission denied
2015-05-15 14:50:23 1761 [ERROR] Do you already have another mysqld server running on socket: /home/data/mysql/mysql.sock ?
2015-05-15 14:50:23 1761 [ERROR] Aborting
2015-05-15 14:50:23 1761 [Note] Binlog end
2015-05-15 14:50:23 1761 [Note] Shutting down plugin 'partition'
2015-05-15 14:50:23 1761 [Note] Shutting down plugin 'INNODB_SYS_DATAFILES'
2015-05-15 14:50:23 1761 [Note] Shutting down plugin 'INNODB_SYS_TABLESPACES'
2015-05-15 14:50:23 1761 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN_COLS'
2015-05-15 14:50:23 1761 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN'
2015-05-15 14:50:23 1761 [Note] Shutting down plugin 'INNODB_SYS_FIELDS'
2015-05-15 14:50:23 1761 [Note] Shutting down plugin 'INNODB_SYS_COLUMNS'
2015-05-15 14:50:23 1761 [Note] Shutting down plugin 'INNODB_SYS_INDEXES'
2015-05-15 14:50:23 1761 [Note] Shutting down plugin 'INNODB_SYS_TABLESTATS'
2015-05-15 14:50:23 1761 [Note] Shutting down plugin 'INNODB_SYS_TABLES'
2015-05-15 14:50:23 1761 [Note] Shutting down plugin 'INNODB_FT_INDEX_TABLE'
2015-05-15 14:50:23 1761 [Note] Shutting down plugin 'INNODB_FT_INDEX_CACHE'
2015-05-15 14:50:23 1761 [Note] Shutting down plugin 'INNODB_FT_CONFIG'
2015-05-15 14:50:23 1761 [Note] Shutting down plugin 'INNODB_FT_BEING_DELETED'
2015-05-15 14:50:23 1761 [Note] Shutting down plugin 'INNODB_FT_DELETED'
2015-05-15 14:50:23 1761 [Note] Shutting down plugin 'INNODB_FT_DEFAULT_STOPWORD'
2015-05-15 14:50:23 1761 [Note] Shutting down plugin 'INNODB_METRICS'
2015-05-15 14:50:23 1761 [Note] Shutting down plugin 'INNODB_BUFFER_POOL_STATS'
2015-05-15 14:50:23 1761 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE_LRU'
2015-05-15 14:50:23 1761 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE'
2015-05-15 14:50:23 1761 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX_RESET'
2015-05-15 14:50:23 1761 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX'
2015-05-15 14:50:23 1761 [Note] Shutting down plugin 'INNODB_CMPMEM_RESET'
2015-05-15 14:50:23 1761 [Note] Shutting down plugin 'INNODB_CMPMEM'
2015-05-15 14:50:23 1761 [Note] Shutting down plugin 'INNODB_CMP_RESET'
2015-05-15 14:50:23 1761 [Note] Shutting down plugin 'INNODB_CMP'
2015-05-15 14:50:23 1761 [Note] Shutting down plugin 'INNODB_LOCK_WAITS'
2015-05-15 14:50:23 1761 [Note] Shutting down plugin 'INNODB_LOCKS'
2015-05-15 14:50:23 1761 [Note] Shutting down plugin 'INNODB_TRX'
2015-05-15 14:50:23 1761 [Note] Shutting down plugin 'InnoDB'
2015-05-15 14:50:23 1761 [Note] InnoDB: FTS optimize thread exiting.
2015-05-15 14:50:23 1761 [Note] InnoDB: Starting shutdown...
2015-05-15 14:50:25 1761 [Note] InnoDB: Shutdown completed; log sequence number 1654303
2015-05-15 14:50:25 1761 [Note] Shutting down plugin 'PERFORMANCE_SCHEMA'
2015-05-15 14:50:25 1761 [Note] Shutting down plugin 'ARCHIVE'
2015-05-15 14:50:25 1761 [Note] Shutting down plugin 'BLACKHOLE'
2015-05-15 14:50:25 1761 [Note] Shutting down plugin 'MEMORY'
2015-05-15 14:50:25 1761 [Note] Shutting down plugin 'CSV'
2015-05-15 14:50:25 1761 [Note] Shutting down plugin 'MyISAM'
2015-05-15 14:50:25 1761 [Note] Shutting down plugin 'MRG_MYISAM'
2015-05-15 14:50:25 1761 [Note] Shutting down plugin 'sha256_password'
2015-05-15 14:50:25 1761 [Note] Shutting down plugin 'mysql_old_password'
2015-05-15 14:50:25 1761 [Note] Shutting down plugin 'mysql_native_password'
2015-05-15 14:50:25 1761 [Note] Shutting down plugin 'binlog'
2015-05-15 14:50:25 1761 [Note] /usr/sbin/mysqld: Shutdown complete
150515 14:50:25 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
你可以尝试重新初始化数据库
sudo /你的目录/mysql/scripts/mysql_install_db --user=mysql --basedir=/你的目录/mysql --datadir=/你的数据库目录
重新初始化之后,尝试能否启动?
[root @localhost ~]# ps aux | grep mysql
root 1460 0.0 0.0 115212 1564 ? Ss 15:17 0:00 /bin/bash /usr/bin/mysql-systemd-start post
root 2996 0.0 0.0 112656 972 pts/0 S+ 15:20 0:00 grep --color=auto mysql
这个文件 /home/data/mysql/mysql.sock 是不存在的
我一开始也是这么做的,一直没解决,后来直接吧 mysql目录软链接到其他盘的目录。这样一个替代方案
骚年们, 你们都修改了 /usr/bin/mysql-systemd-start 这个文件吗?跟my.cnf一样,datadir和sock一样要修改的哦!
centos7.0+yum mysql 5.6下刚折腾好,费了大半天。
引用来自“夜雨轻茶”的评论
骚年们, 你们都修改了 /usr/bin/mysql-systemd-start 这个文件吗?跟my.cnf一样,datadir和sock一样要修改的哦!
centos7.0+yum mysql 5.6下刚折腾好,费了大半天。
请问这个问题解决了吗?