標籤:mysql
MySQL Study案例之--MySQL用戶端串連故障
系統內容:
作業系統:RedHat EL6
DB Soft: MySQL 5.6.4-m7
在系統安裝了源碼包 MySQL 5.6.4-m7版本,啟動服務後,用戶端串連失敗 !
[[email protected] ~]# cd /usr/local/mysql/[[email protected] mysql]# cd bin[[email protected] bin]# ./mysql -u root -pEnter password: ERROR 2002 (HY000): Can‘t connect to local MySQL server through socket ‘/tmp/mysql.sock‘ (13)--串連server失敗[[email protected] bin]# mysql -u root -pEnter password: Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 2Server version: 5.1.66 Source distributionCopyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.mysql>
--連入了系統內建的5.1.66的版本
解決方案:
查看設定檔,並修改
[[email protected] bin]# cat /etc/my.cnf[mysqld]datadir=/var/lib/mysqlsocket=/var/lib/mysql/mysql.sockuser=mysql# Disabling symbolic-links is recommended to prevent assorted security riskssymbolic-links=0[mysqld_safe]log-error=/var/log/mysqld.logpid-file=/var/run/mysqld/mysqld.pid更改socket參數:[[email protected] bin]# vi /etc/my.cnf[mysqld]datadir=/var/lib/mysqlsocket=/tmp/mysql.sock#socket=/var/lib/mysql/mysql.sockuser=mysql# Disabling symbolic-links is recommended to prevent assorted security riskssymbolic-links=0[mysqld_safe]log-error=/var/log/mysqld.logpid-file=/var/run/mysqld/mysqld.pid~
驗證:
停止mysqld進程:[[email protected] bin]# ps -ef |grep mysqlroot 4482 4456 0 12:27 pts/3 00:00:00 /bin/sh /usr/bin/mysqld_safe --user=mysqlmysql 4553 4482 0 12:27 pts/3 00:00:00 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --user=mysql --log-error=/var/log/mysqld.log --pid-file=/var/run/mysqld/mysqld.pid --socket=/var/lib/mysql/mysql.sockroot 4590 4456 1 12:29 pts/3 00:00:00 grep mysql[[email protected] bin]# pkill mysql[[email protected] bin]# ps -ef |grep mysql150206 12:30:03 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid endedroot 4597 4456 0 12:30 pts/3 00:00:00 grep mysql[1]+ Done mysqld_safe --user=mysql (wd: ~)(wd now: /usr/local/mysql/bin)[[email protected] bin]# ps -ef |grep mysqlroot 4599 4456 0 12:30 pts/3 00:00:00 grep mysql重新啟動mysqld進程:[[email protected] bin]# ./mysqld_safe &[1] 4602[[email protected] bin]# 150206 12:30:17 mysqld_safe Logging to ‘/var/log/mysqld.log‘.150206 12:30:18 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql用戶端串連成功:[[email protected] bin]# ./mysql -u root -pEnter password: Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 1Server version: 5.6.4-m7 Source distributionCopyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.mysql>mysql> status--------------./mysql Ver 14.14 Distrib 5.6.4-m7, for Linux (x86_64) using EditLine wrapperConnection id: 3Current database:Current user: [email protected]SSL: Not in useCurrent pager: stdoutUsing outfile: ‘‘Using delimiter: ;Server version: 5.6.4-m7 Source distributionProtocol version: 10Connection: Localhost via UNIX socketServer characterset: latin1Db characterset: latin1Client characterset: utf8Conn. characterset: utf8UNIX socket: /tmp/mysql.sockUptime: 26 min 33 secThreads: 1 Questions: 6 Slow queries: 0 Opens: 66 Flush tables: 1 Open tables: 59 Queries per second avg: 0.003--------------mysql>
@至此,問題解決
本文出自 “天涯客的blog” 部落格,請務必保留此出處http://tiany.blog.51cto.com/513694/1612401
MySQL Study案例之--MySQL用戶端串連故障