1. 程式人生 > >CentOs mysql 的安裝與預設安裝目錄修改

CentOs mysql 的安裝與預設安裝目錄修改

如果報錯:
/usr/bin/mysqladmin: connect toserver at 'localhost' failed
error: 'Can't connect to local MySQL server through socket'/var/lib/mysql/mysql.sock' (2)'
Check that mysqld is running and that the socket: '/var/lib/mysql/mysql.sock'exists!
(1)先停止服務:service mysql stop
(2)修改/etc/my.conf:
[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
If there is not currently asection called [client], add one at the bottom of the file and copy the socket=line under the [mysqld] section such as:
[client]
socket=/var/lib/mysql/mysql.sock
(3)執行/usr/local/mysql/bin/mysqld_safe& service mysql start