programing

소켓 '/tmp/mysql'을(를) 통해 로컬 MySQL 서버에 연결할 수 없습니다.양말' (2)

mailnote 2023. 10. 13. 22:24
반응형

소켓 '/tmp/mysql'을(를) 통해 로컬 MySQL 서버에 연결할 수 없습니다.양말' (2)

내 단말기에서 mysql 클라이언트를 실행하려고 합니다.최신 mysql gem을 설치했습니다.

 ➜  ~ git:(master) ✗ ruby -v
    ruby 1.8.7 (2010-01-10 patchlevel 249) [universal-darwin11.0]
    ➜  ~ git:(master) ✗ rails -v
    Rails 2.3.14
    ➜  ~ git:(master) ✗ which mysql
    mysql: aliased to nocorrect mysql
    ➜  ~ git:(master) ✗ which ruby
    /usr/bin/ruby
    ➜  ~ git:(master) ✗ which rails
    /usr/bin/rails
    ➜  ~ git:(master) ✗ gem list

*** LOCAL GEMS ***

actionmailer (2.3.14)
actionpack (2.3.14)
activerecord (2.3.14)
activeresource (2.3.14)
activesupport (2.3.14)
builder (2.1.2)
bundler (1.0.21)
capistrano (2.9.0)
capybara (0.3.9)
cgi_multipart_eof_fix (2.5.0)
childprocess (0.2.2)
columnize (0.3.4, 0.3.3)
cucumber (0.9.4)
cucumber-rails (0.3.2)
culerity (0.2.15)
daemons (1.1.4)
database_cleaner (0.6.7)
diff-lcs (1.1.3)
expertiza-authlogic (2.1.6.1)
fastercsv (1.5.4)
fastthread (1.0.7)
ffi (1.0.10, 1.0.9)
gdata (1.1.2)
gem_plugin (0.2.3)
gherkin (2.2.9)
highline (1.6.2)
hoptoad_notifier (2.4.11)
json (1.4.6)
json_pure (1.6.1)
linecache (0.46)
mime-types (1.16)
mongrel (1.1.5)
mysql (2.8.1)
mysql2 (0.3.7)
net-scp (1.0.4)
net-sftp (2.0.5)
net-ssh (2.2.1)
net-ssh-gateway (1.1.0)
nokogiri (1.5.0)
rack (1.1.2)
rack-test (0.6.1)
rails (2.3.14)
rake (0.9.2)
rbx-require-relative (0.0.5)
rdoc (3.11)
RedCloth (4.2.8)
rgl (0.4.0)
ruby-debug (0.10.4)
ruby-debug-base (0.10.4)
rubyzip (0.9.4)
selenium-webdriver (2.8.0, 2.7.0)
stream (0.5)
term-ansicolor (1.0.7, 1.0.6)

➜  expertiza git:(master) ✗ sudo su
Password:
sh-3.2# mysql -u root -p
Enter password: 
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
sh-3.2# 

위의 오류를 제거할 수 없습니다.내가 만든 것은mysql.sock file인에/Users/HPV/expertiza/tmp/sockets. 내가 작성한 파일에mysql.default_socket =/expertiza/tmp/sockets/mysql.sock.

내가 뭘 잘못하고 있는 거지?

감사합니다!

서버를 설치하고 시작하려면 지시에 따라야 합니다.

MySQL을 설치한 방법에 따라 명령이 달라집니다.먼저 시도해 보십시오.

sudo/도서관/스타트업항목/MySQLCOM/MySQLCOM 시작

실패할 경우:

cd/usr/local/
sudo ./bin/mysqld_safe
(필요한 경우 비밀번호 입력)
(프레스 컨트롤-Z)
bg

또한 이 오류가 발생하여 홈브루를 통해 mysql을 설치한 경우 다음과 같이 작동함을 알 수 있었습니다("5.6.12"를 자신의 버전으로 변경해야 함에도 불구하고).

/usr/local/Cellar/mysql/5.6.12/bin/mysql.server 재시작

MySQL이 작동할 때마다 이 파일을 사용할 수 있도록 홈 디렉토리에 ~/restartMysql.sh 파일을 만들었습니다.

명령줄에서 다음을 실행합니다.

$ mysql.server start

게시물을 통해 도움이 되었습니다. 여기에 단계를 다시 작성하겠습니다(참고: 명령어의 출력도 작성합니다.당신이 정상 궤도에 올랐다는 것을 알 수 있도록 하기 위해서입니다.

실행 중인 경우 서버를 먼저 중지합니다.

[root@servert1 ~]# /etc/init.d/mysqld stop
Stopping MySQL: [ OK ]

다른 실에 실타래를 치다

[root@servert1 ~]# mysqld_safe --skip-grant-tables &    
[1] 13694    
[root@servert1 ~]# Starting mysqld daemon with databases from /var/lib/mysql

별도의 셸 창을 열고 타자 치기

[root@servert1 ~]# mysql -u root

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 1

Server version: 5.0.77 Source distribution



Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql 사용을 시작합니다.

mysql> use mysql; 

Reading table information for completion of table and column names

You can turn off this feature to get a quicker startup with -A



Database changed

최신 정보를 제공합니다.user새 암호를 사용하여 수동으로 테이블을 작성합니다(참고: 자유롭게 입력하십시오.mysql> show tables; 단지 당신이 어디에 있는지에 대한 관점을 얻기 위해)

참고: MySQL 5.7 암호는authenication_stringtable, 그래서 명령어는update user set authentication_string=password('testpass') where user='root';

mysql> update user set password=PASSWORD("testpass") where User='root';

Query OK, 3 rows affected (0.05 sec)

Rows matched: 3 Changed: 3 Warnings: 0

플러시 권한(이 권한이 무엇인지 잘 모르겠습니다.작동합니다.)

mysql> flush privileges; 

Query OK, 0 rows affected (0.04 sec)

멈춰

mysql> quit

Bye

서버를 중지

참고: OS X 또는 macOS에서는mysql.server위치:/usr/local/mysql/support-files/.

mysql.server stop

Shutting down MySQL
.130421 09:27:02 mysqld_safe mysqld from pid file /usr/local/var/mysql/mycomputername.local.pid ended
 SUCCESS! 
[2]-  Done                    mysqld_safe --skip-grant-tables

데몬이 실행 중인 다른 포탄 창을 죽입니다(확인하기 위해).

이제 가셔도 좋습니다! 해보세요.

[root@servert1 ~]#  mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.6.10 Source distribution

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> 

알았어!

누군가에게 도움이 되었으면 좋겠습니다.저는 같은 오류를 범하고 있었지만, 다른 사람들과는 다른 이유로 일어난 것 같습니다.

저는 센트OS 기계 2대를 가지고 있습니다.

이전 기계를 MySQL 5.6으로 업그레이드한 것을 모르고 my.cnf를 새 기계에 복사했고 새 기계에는 5.5가 설치되어 있었습니다.5.6 전용 지침에 대해 언급했을 때 MySQL은 예상대로 시작했습니다.(지금은 업그레이드를 실행하고 있기 때문에 매우 유용한 기능을 적용할 수 있습니다.innodb_buffer_pool_dump_at_shutdown그리고.innodb_buffer_pool_load_at_startup항)

최소한의 나의 .cnf를 시도하는 것을 제안합니다.MySQL이 시작되면 문제의 원인을 찾은 것입니다.

MySQL 서버를 설치해야 하거나, mysql 사이트에 설치 패키지가 있거나, macports를 통해 설치할 수 있습니다(darwin11 라인에서 가정합니다).포트를 통해 내 것을 설치했고 소켓은 /opt/local/var/run/mysql5/에 있습니다.

저 같은 경우에는 tmp 폴더 설정이 잘 안 되어 있습니다.결국 다음과 같은 단계를 거치게 됩니다.

1. cd /

2. ln -s private/tmp /tmp

언급URL : https://stackoverflow.com/questions/7843731/cant-connect-to-local-mysql-server-through-socket-tmp-mysql-sock-2

반응형