1.在 /ect/my.cnf 修改 datadir=/data/mysqlData/mysql(/data/mysalData为你想要存储数据的目录) 2.[tomh@workstation001 ~]$ sudo su - [root@workstation001 ~]# [root@workstation001 ~]# service mysqld stop Stopping mysqld (via systemctl): [ OK ] [root@workstation001 ~]# mv /var/lib/mysql/ /opt/ [root@workstation001 ~]# ln -s /opt/mysql /var/lib/ [root@workstation001 ~]# ls -la /var/lib/mysql lrwxrwxrwx 1 root root 10 Feb 26 23:02 /var/lib/mysql -> /opt/mysql [root@workstation001 ~]# service mysqld start Starting mysqld (via systemctl): [ OK ] [root@workstation001 ~]# mysql -uroot Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.5.18-log MySQL Community Server (GPL) mysql> show databases; ... | Database | +-----------------------+ | information_schema | | mysql | | performance_schema | | test If this is working, you’re up and running. Should you get a message that says
ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’
then add the following to your /etc/my.cnf
[client]
socket = /srv/mysql/mysql.sock
Optionally you can just use
$ mysql -u root -p --protocol tcp
to avoid connecting via the socket.

分类: web

标签: