CentOS6.5上安装MySQL5.6及更改数据库目录

前端之家收集整理的这篇文章主要介绍了CentOS6.5上安装MySQL5.6及更改数据库目录前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

CentOS6.5上安装MysqL5.6及更改数据库目录


1 安装MysqL数据库

参考: http://www.jb51.net/article/58096.htm

1) 查询已经安装的MysqL:

# rpm -qa | grep -i MysqL
MysqL-libs-5.1.73-3.el6_5.x86_64 (系统自带,不删除)

2) 删除旧的:

//# rpm -e --nodeps MysqL-libs-5.1.73-3.el6_5.x86_64

3) 下载安装包:

# wget ftp://pub:pub@pepstack.com/rpm/MysqL-server-5.6.27-1.el6.x86_64.rpm
# wget ftp://pub:pub@pepstack.com/rpm/MysqL-devel-5.6.27-1.el6.x86_64.rpm
# wget ftp://pub:pub@pepstack.com/rpm/MysqL-client-5.6.27-1.el6.x86_64.rpm

4) 安装MysqL数据库

# rpm -ivh MysqL-server-5.6.27-1.el6.x86_64.rpm MysqL-client-5.6.27-1.el6.x86_64.rpm MysqL-devel-5.6.27-1.el6.x86_64.rpm
error: Failed dependencies:
libnuma.so.1()(64bit) is needed by MysqL-server-5.6.27-1.el6.x86_64
libnuma.so.1(libnuma_1.1)(64bit) is needed by MysqL-server-5.6.27-1.el6.x86_64
libnuma.so.1(libnuma_1.2)(64bit) is needed by MysqL-server-5.6.27-1.el6.x86_64
# yum install numactl
# rpm -ivh MysqL-server-5.6.27-1.el6.x86_64.rpm MysqL-client-5.6.27-1.el6.x86_64.rpm MysqL-devel-5.6.27-1.el6.x86_64.rpm
# rpm -qa | grep -i MysqL
MysqL-server-5.6.27-1.el6.x86_64
MysqL-client-5.6.27-1.el6.x86_64
MysqL-devel-5.6.27-1.el6.x86_64

# chkconfig MysqL on

5) 查看使用的my.cnf

# MysqL --help | grep my.cnf

6) 复制一个my.cnf

# cp /usr/share/doc/MysqL-server-5.6.27/my-default.cnf /etc/my.cnf

7) 启动MysqL server
# service MysqL start
# cat /root/.MysqL_secret
# The random password set for the root user at Mon Apr 24 16:37:19 2017 (local time): 1VSt46KA3RHO1ZhJ

# MysqL u root -p1VSt46KA3RHO1ZhJ

MysqL> SET PASSWORD = PASSWORD('abc123');

2 更换MysqL数据库的数据文件目录

默认在:
/var/lib/MysqL

1) 查看datadir

# MysqLadmin -u root -p variables|grep datadir
| datadir | /var/lib/MysqL/

2) 更换到 /data/MysqL

# mv /var/lib/MysqL /data/ # cp /usr/share/MysqL/my-default.cnf /etc/my.cnf # vi /etc/my.cnf [client] port = 3306 socket = /data/MysqL/MysqL.sock (必须) [MysqLd] port = 3306 datadir=/data/MysqL socket=/data/MysqL/MysqL.sock # vi /etc/init.d/MysqL datadir=/data/MysqL 启动MysqL: # service MysqL start or # /etc/init.d/MysqL start 查看数据库的目录: # MysqLadmin -u root -p variables|grep datadir Enter password: | datadir | /data/MysqL/ 结束!

猜你在找的CentOS相关文章