Centos6.5 yum 安裝MySQL5.5 並修改數據庫路徑

Webtatic EL6 for CentOS/RHEL 6.x
一、添加源
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el6/latest.rpmhtml

二、安裝mysql5.5
yum install mysql55w mysql55w-servermysql

安裝完成後查看數據庫安裝的位置(這個版本的的數據分了好多文件夾,可是以/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/mysqlweb

三、更換數據庫位置
[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=0sql

[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.pidsocket

在啓動 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).net


若是是權限問題,則先改變權限 #chown -R mysql:mysql /opt/mysql
發現仍是報錯,在my.cnf中加入
[client] 
socket=/opt/mysql/mysql.sockserver

ps:在遷移數據的時候遇到各類錯誤,參考了不少文章htm

http://www.cnblogs.com/visi_zhangyang/archive/2012/03/05/2380531.htmlblog

http://www.educity.cn/wenda/592852.html

相關文章
相關標籤/搜索