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/
结束!