Webtatic EL6 for CentOS/RHEL 6.x
1、添加源
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el6/latest.rpm
2、安装mysql5.5
yum install mysql55w mysql55w-server
安装完成后查看数据库安装的位置(这个版本的的数据分了好多文件夹,但是以/var/lib/mysq为主)
[root@localhost ~]# find / -name mysql
/var/lib/mysql
/usr/share/mysql
/usr/lib64/mysql
/usr/lib64/perl5/auto/DBD/mysql
/usr/lib64/perl5/DBD/mysql
/usr/bin/mysql
3、更换数据库位置
[root@localhost opt]# cp -rf /var/lib/mysql /opt/
修改my.cnf
原配置文件
[root@localhost ~]# vi /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
修改为
datadir=/opt/mysql
socket=/opt/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
在启动 mysqld: [确定]
[root@localhost opt]# chkconfig mysqld on
[root@localhost opt]# service mysqld start
正在启动 mysqld: [确定]
[root@localhost opt]# mysql -u root
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
如果是权限问题,则先改变权限 #chown -R mysql:mysql /opt/mysql
发现还是报错,在my.cnf中加入
[client]
socket=/opt/mysql/mysql.sock
ps:在迁移数据的时候遇到各种错误,参考了很多文章
(责任编辑:最模板) |