# ./bin/mysql
ERROR 2002 (HY000): Can't connectto local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
出现错误。
修改配置文件:
vim/etc/my.cnf
在末尾添加:
[client]
default-character-set=utf8
socket=/usr/local/mysql/data/mysql.sock
这里需要注意的是:不要在中间插入:因为 my.cnf 格式的模块是松散的没有明确的结束标志。容易把别的字段的配置隔断。造成无法解析。
# ./bin/mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection> Server version: 5.6.17 Source distribution
Copyright (c) 2000, 2014, Oracle and/or itsaffiliates. All rights reserved.
Oracle is a registered trademark of OracleCorporation and/or its
affiliates. Other names may be trademarksof their respective
owners.
Type 'help;' or '\h' for help. Type '\c' toclear the current input statement.
mysql>
今天重新安装mysql做mysql主从。发现原来哪些配置都是安装的时候加入的。如果需要修改只能通过修改配置文件my.cnf在启动的时候重新读取配置文件my.cnf 特别是在做多个 mysql实例的时候。就需要这些配置的支持。安装mysql的一些编译参数
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
#指定安装路径
-DMYSQL_DATADIR=/usr/local/mysql/data \
#指定mysql数据(库)文件的存放路径
-DSYSCONFDIR=/etc \
#配置文件
-DWITH_MYISAM_STORAGE_ENGINE=1 \
#引擎支持myisam
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
#引擎支持 innodb
-DWITH_MEMORY_STORAGE_ENGINE=1 \
#引擎支持 memory-storage
-DWITH_READLINE=1 \
-DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock \
#指定mysql的sock文件路径
-DMYSQL_TCP_PORT=3306 \
#指定mysql端口号
成功连接数据库。开始新的学习篇章。