Tải bản đầy đủ - 0 (trang)
ERROR 2002: Can¡¯t connect to local MySQL server through socket ¡®/ tmp/ mysql. sock¡¯ ( 111)

ERROR 2002: Can¡¯t connect to local MySQL server through socket ¡®/ tmp/ mysql. sock¡¯ ( 111)

Tải bản đầy đủ - 0trang

46



Installing MySQL



On Solaris, it would be

ps -ef | grep mysqld



On other Unix systems, the command would follow either the former

(Linux/FreeBSD) style or the latter (Solaris) . If the command produces no output, mysqld is not running. If it is running, you’ll see a line or several lines from

the process list containing mysqld. If the server is running, it is simply listening

on a different socket than the one the command client thinks it is listening on.

The discrepancy can happen because the command-line client was compiled

with different defaults, the server was told to listen on a different socket, or

possibly there is an option file (my.cnf) that is telling the client to use the wrong

socket. There are many ways to correct the discrepancy, and one is usually not

any better than the other. One way is to force a TCP/IP connection to the server

through the local interface (instead of using a Unix socket); once the connection is established, ask the server which socket it is listening on, and then tell

the command-line client either on the command line or in the .my.cnf option file

in the home directory to use the correct socket. Here is an example:

sasha@mysql:~ > mysql —host=127.0.0.1

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

Your MySQL connection id is 3 to server version: 3.23.43-Max-log

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

mysql> show variables like 'socket';

+---------------+---------------------------+

| Variable_name | Value

|

+---------------+---------------------------+

| socket

| /var/lib/mysql/mysql.sock |

+---------------+---------------------------+

1 row in set (0.08 sec)

mysql> exit

Bye

sasha@mysql:~ > mysql —socket=/var/lib/mysql/mysql.sock

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

Your MySQL connection id is 4 to server version: 3.23.43-Max-log

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

mysql> exit

Bye



Other Problems

If the symptoms you are getting do not fit into any of the above categories, you

should begin by examining the MySQL error log in the data directory. It usually



www.it-ebooks.info



Troubleshooting



47



will have a diagnostic message that you can attempt to decipher. In many cases,

the problem and the solution become quite obvious from the message. In other

cases, there might be no message, or the message is not directly related to the

actual problem. Strange behavior sometimes is the result of binary incompatibility. If you were using a binary distribution, try compiling from source to see

if you have better luck.

If compiling from source does not help, the first thing I recommend that you

do is write to mysql@lists.mysql.com in hopes that some experienced

user might be able to help you, or purchase a MySQL support contract from

https://order.mysql.com/ and have a MySQL support team member work with

you to resolve the case.

If you are experienced in C++, you might try debugging the problem. Add

--with-debug to the ./configure options, and add --debug to the mysql_install_db

and/or safe_mysqld arguments. This will create a trace file, /tmp/mysqld.trace,

containing a sequence of function calls and various intermediate values

that you can examine and compare against the source to try to understand

what is going on. Usually the last few lines of the trace file are the most interesting, although sometimes the trouble happens earlier. You may also

add fprintf(stderr, ...) calls. Your debugging messages will be redirected to the

error log.

Usually the problem is that some supposedly standard API call does not behave

quite the way MySQL team thought it should on your system. For example,

fcntl() call may return the wrong value, accept() might fail some unexpected

error requiring, or perhaps pthread_mutex_trylock() might have its return values inverted returning 1 on success and 0 when the mutex is locked, instead of

the other way around. The problems can usually be tracked down and fixed

quite easily by a person familiar with C/C++ and MySQL source code.



www.it-ebooks.info



www.it-ebooks.info



CHAPTER



4



Testing Your MySQL Installation



fter installing MySQL and performing a number of basic connectivity

and functionality tests described in chapter 3, you may want to dig a little deeper and probe the limits of your system by running a number of

more thorough tests. In this chapter, we describe five types of tests:



A

■■



The standard MySQL test suite (mysql-test-run)



■■



The server limit test (crash-me)



■■



The one-threaded standard MySQL benchmark



■■



The basic multithreaded benchmark (mysqlsyseval)



■■



Your own tests



The Standard MySQL Test Suite (mysql-test-run)

This test suite is employed frequently during the development process, and

MySQL binaries are checked with it prior to each release. Currently, it is available only on a Unix platform, although an effort is in progress to port it to

Windows.

The purpose of this test suite is to validate the frequently used functionality in

MySQL. It serves as a regression test to ensure that new code has not broken

what used to work before. You will want to run this test if you built the binary

yourself, or if you are installing it on a system where you suspect binary compatibility problems.



49



www.it-ebooks.info



50



Te s t i n g Yo u r M y S Q L I n s t a l l a t i o n



If you are using a binary installation, you can find mysql-test-run in

/usr/local/mysql/mysql-test. To run the test, change to the directory where the

test is located and execute ./mysql-test-run. You will see output similar to that

shown in Listing 4.1.



NOTE

If you installed from source, you should simply do make test before you do make

install. If you installed from RPM, you should install the MySQL-Bench package and

run the tests from /usr/share/mysql-test.



Installing Test Databases

Removing Stale Files

Installing Master Databases

020607 6:42:09 ../sql/mysqld: Shutdown Complete

Installing Slave Databases

020607 6:42:09 ../sql/mysqld: Shutdown Complete

Starting MySQL daemon

Loading Standard Test Databases

Starting Tests

TEST

USER

——————————————————————————————————alias

0.00

alter_table

0.00

analyse

0.02

auto_increment

0.02

backup

0.05

bdb-crash

0.00

bdb-deadlock

....

bdb

....

bench_count_distinct

0.09

bigint

0.00

binary

0.00

case

0.02

check

47.55

comments

0.02

compare

0.01

count_distinct

0.02

create

0.04

delayed

0.01

delete

0.01

dirty-close

0.02

distinct

0.07



Listing 4.1



SYSTEM



ELAPSED



0.01

0.02

0.01

0.02

0.01

0.01

....

....

0.01

0.01

0.01

0.01

0.38

0.01

0.01

0.01

0.01

0.02

0.01

0.01

0.01



0.19

0.30

0.11

0.28

0.30

0.08

....

....

0.46

0.11

0.16

0.20

123.52

0.15

0.17

0.28

0.42

3.21

0.28

0.33

1.09



Common results generated by mysql-test-run. (continues)



www.it-ebooks.info



RESULT

[

[

[

[

[

[

[

[

[

[

[

[

[

[

[

[

[

[

[

[

[



pass ]

pass ]

pass ]

pass ]

pass ]

pass ]

skipped ]

skipped ]

pass ]

pass ]

pass ]

pass ]

pass ]

pass ]

pass ]

pass ]

pass ]

pass ]

pass ]

pass ]

pass ]



The Standard MySQL Test Suite (mysql-test-run)



drop

empty_table

err000001

explain

flush

flush_table

foreign_key

fulltext

fulltext_cache

fulltext_left_join

fulltext_multi

fulltext_order_by

fulltext_update

func_concat

func_crypt

func_date_add

func_equal

func_group

func_if

func_in

func_isnull

func_like

func_math

func_misc

func_op

func_regexp

func_set

func_str

func_system

func_test

func_time

func_timestamp

gcc296

gemini

group_by

having

heap

innodb

ins000001

insert

insert_select

isam

isolation

join

join_crash

join_outer

key



Listing 4.1



0.04

0.02

0.01

0.02

0.03

0.03

0.02

0.03

0.01

0.03

0.02

0.03

0.02

0.01

0.02

0.03

0.01

0.05

0.05

0.01

0.00

0.03

0.00

0.01

0.03

0.01

0.01

0.03

0.01

0.03

0.06

0.03

0.01

....

0.06

0.01

0.01

....

0.02

0.01

0.01

0.07

....

0.05

0.03

0.11

0.04



0.00

0.02

0.00

0.01

0.01

0.00

0.00

0.01

0.01

0.00

0.00

0.02

0.00

0.02

0.00

0.01

0.00

0.01

0.00

0.00

0.03

0.00

0.02

0.01

0.01

0.01

0.00

0.02

0.01

0.01

0.03

0.00

0.00

....

0.00

0.01

0.02

....

0.00

0.01

0.01

0.02

....

0.01

0.01

0.02

0.01



0.32

0.17

0.04

0.17

0.87

0.15

0.13

0.33

0.11

0.16

0.25

0.15

0.24

0.22

0.16

0.14

0.19

0.41

0.17

0.13

0.10

0.16

0.18

0.08

0.16

0.26

0.10

0.94

0.02

0.15

0.47

0.17

0.09

....

0.47

0.22

0.56

....

0.04

0.14

0.20

6.18

....

0.77

0.25

1.41

0.36



Common results generated by mysql-test-run. (continues)



www.it-ebooks.info



[

[

[

[

[

[

[

[

[

[

[

[

[

[

[

[

[

[

[

[

[

[

[

[

[

[

[

[

[

[

[

[

[

[

[

[

[

[

[

[

[

[

[

[

[

[

[



pass ]

pass ]

pass ]

pass ]

pass ]

pass ]

pass ]

pass ]

pass ]

pass ]

pass ]

pass ]

pass ]

pass ]

pass ]

pass ]

pass ]

pass ]

pass ]

pass ]

pass ]

pass ]

pass ]

pass ]

pass ]

pass ]

pass ]

pass ]

pass ]

pass ]

pass ]

pass ]

pass ]

skipped ]

pass ]

pass ]

pass ]

skipped ]

pass ]

pass ]

pass ]

pass ]

skipped ]

pass ]

pass ]

pass ]

pass ]



51



52



Te s t i n g Yo u r M y S Q L I n s t a l l a t i o n



key_diff

key_primary

keywords

kill

limit

lock

merge

myisam

null

null_key

odbc

order_by

outfile

overflow

raid

range

rename

replace

rollback

rpl000001

rpl000002

rpl000003

rpl000004

rpl000005

rpl000006

rpl000007

rpl000008

rpl000009

rpl000010

rpl000011

rpl000012

rpl000013

rpl000014

rpl000015

rpl000016

rpl000017

rpl000018

rpl_alter

rpl_empty_master_crash

rpl_get_lock

rpl_mystery22

rpl_skip_error

rpl_sporadic_master

sel000001

sel000002

sel000003

sel000031



Listing 4.1



0.01

0.01

0.01

0.02

0.02

0.02

0.05

0.06

0.03

0.03

0.02

0.06

0.02

0.03

....

0.02

0.02

0.01

0.02

0.06

0.04

0.04

0.02

0.03

0.03

0.04

0.04

0.02

0.02

0.04

0.05

0.01

0.03

0.02

0.16

0.03

0.01

0.02

0.02

0.55

0.01

0.03

0.02

0.01

0.02

0.01

0.01



0.01

0.00

0.01

0.01

0.00

0.01

0.02

0.02

0.01

0.00

0.00

0.00

0.01

0.01

....

0.01

0.01

0.03

0.00

0.01

0.00

0.00

0.00

0.02

0.01

0.01

0.01

0.02

0.03

0.02

0.02

0.02

0.02

0.01

0.03

0.00

0.01

0.01

0.02

0.13

0.02

0.00

0.01

0.01

0.01

0.02

0.01



0.17

0.15

0.15

5.18

0.12

8.36

0.64

6.12

0.14

0.29

0.14

0.68

0.14

0.14

....

0.70

0.21

0.18

0.14

3.35

0.23

0.25

0.27

0.25

0.28

0.29

0.34

0.25

4.36

0.31

0.34

0.44

0.41

0.69

0.54

0.10

0.14

0.22

0.18

6.23

1.42

0.12

12.48

0.05

0.06

0.05

0.10



Common results generated by mysql-test-run. (continues)



www.it-ebooks.info



[

[

[

[

[

[

[

[

[

[

[

[

[

[

[

[

[

[

[

[

[

[

[

[

[

[

[

[

[

[

[

[

[

[

[

[

[

[

[

[

[

[

[

[

[

[

[



pass ]

pass ]

pass ]

pass ]

pass ]

pass ]

pass ]

pass ]

pass ]

pass ]

pass ]

pass ]

pass ]

pass ]

skipped ]

pass ]

pass ]

pass ]

pass ]

pass ]

pass ]

pass ]

pass ]

pass ]

pass ]

pass ]

pass ]

pass ]

pass ]

pass ]

pass ]

pass ]

pass ]

pass ]

pass ]

pass ]

pass ]

pass ]

pass ]

pass ]

pass ]

pass ]

pass ]

pass ]

pass ]

pass ]

pass ]



The Standard MySQL Test Suite (mysql-test-run)



sel000032

0.02

sel000033

0.02

sel000100

0.01

select

2.90

select_safe

0.02

show_check

0.04

status

0.02

tablelock

0.02

temp_table

0.02

truncate

0.02

type_blob

0.09

type_date

0.01

type_datetime

0.03

type_decimal

0.07

type_enum

0.03

type_float

0.03

type_ranges

0.04

type_set

0.01

type_time

0.02

type_timestamp

0.02

type_uint

0.02

type_year

0.02

update

0.03

user_var

0.01

varbinary

0.02

variables

0.03

warnings

0.02

——————————————————————————————————-



0.02

0.01

0.00

0.09

0.01

0.01

0.01

0.01

0.01

0.00

0.00

0.01

0.00

0.01

0.02

0.00

0.01

0.01

0.01

0.00

0.00

0.01

0.00

0.01

0.01

0.00

0.00



0.18

0.18

0.18

96.82

0.26

0.95

0.69

0.30

0.61

0.14

1.29

0.80

0.35

1.04

2.76

0.31

0.86

0.15

0.19

0.31

0.11

0.45

0.34

0.18

0.10

0.28

0.15



[

[

[

[

[

[

[

[

[

[

[

[

[

[

[

[

[

[

[

[

[

[

[

[

[

[

[



pass

pass

pass

pass

pass

pass

pass

pass

pass

pass

pass

pass

pass

pass

pass

pass

pass

pass

pass

pass

pass

pass

pass

pass

pass

pass

pass



53



]

]

]

]

]

]

]

]

]

]

]

]

]

]

]

]

]

]

]

]

]

]

]

]

]

]

]



Ending Tests

Shutting-down MySQL daemon

Master shutdown finished

Slave shutdown finished

All 136 tests were successful.



Listing 4.1



Common results generated by mysql-test-run. (continued)



Note that the test suite starts up its own server instance on a nonstandard port.

It does not run against your currently executing server.

When a test passes, you will see the [ pass ] message on the right side of the test

line. Otherwise, the message will say [ fail ]. If the test ran to completion, but

produced incorrect results, you will see the output diff showing the differences

between expected and actual results. If the test failed for a different reason

(e.g., a server crash), the message will explain at what stage the problem

occurred. In any case, you will see a message advising you to report the bug.

When reporting the failure of the test suite on your system, MySQL AB wants

you to follow the guidelines in the manual found at www.mysql.com/doc/



www.it-ebooks.info



54



Te s t i n g Yo u r M y S Q L I n s t a l l a t i o n



en/Reporting_mysqltest_bugs.html. For your convenience, I have quoted them

in the following note.



Reporting Test Suite Failures to MySQL AB

“If your MySQL version doesn’t pass the test suite you should do the following:

Don’t send a bug report before you have found out as much as possible of what

when wrong! When you do it, please use the mysqlbug script so that we can get

information about your system and MySQL version. See section 1.6.2.3 How to

Report Bugs or Problems.

Make sure to include the output of mysql-test-run, as well as contents of all

reject files in mysql-test/r directory.

If a test in the test suite fails, check if the test fails also when run by its own:

cd mysql-test

mysql-test-run --local test-name



If this fails, then you should configure MySQL with —with-debug and run mysqltest-run with the --debug option. If this also fails send the trace file

`var/tmp/master.trace’ to ftp://support.mysql.com/pub/mysql/secret so that we

can examine it. Please remember to also include a full description of your system, the

version of the mysqld binary and how you compiled it.

Try also to run mysql-test-run with the --force option to see if there is any other test

that fails.

If you have compiled MySQL yourself, check our manual for how to compile MySQL

on your platform or, preferable, use one of the binaries we have compiled for you at

http://www.mysql.com/downloads/. All our standard binaries should pass the test

suite !

If you get an error, like Result length mismatch or Result content mismatch it means

that the output of the test didn’t match exactly the expected output. This could be a

bug in MySQL or that your mysqld version produces slight different results under

some circumstances. Failed test results are put in a file with the same base name as

the result file with the .reject extension. If your test case is failing, you should do a

diff on the two files. If you cannot see how they are different, examine both with od c and also check their lengths.

If a test fails totally, you should check the logs file in the mysql-test/var/log directory

for hints of what went wrong.

If you have compiled MySQL with debugging you can try to debug this by running

mysql-test-run with the --gdb and/or --debug options. See section E.1.2 Creating

Trace Files. If you have not compiled MySQL for debugging you should probably do

that. Just specify the --with-debug options to configure! See section 2.3 Installing a

MySQL Source Distribution.”



www.it-ebooks.info



The Ser ver Limit Test (crash-me)



55



If you do not have enough time to recompile with the —debug option, or for

some other reason are unable to follow all of the preceding steps, you should at

least use mysqlbug script to gather the system information, include the logs

from the mysql-test/var/log directory, report the name of the test that failed, and

provide the console output of mysql-test-run script related to the failed test.

Failure reports should be sent to bugs@lists.mysql.com. Subscription to the list

is not required to post.



The Server Limit Test (crash-me)

The crash-me test name is rather self-explanatory. It explores the limits of the

server to see how it will respond and whether it will crash when given certain

types of input, such as

■■



Using particularly long queries



■■



Handling requests to create a table with a large number of columns



■■



Creating a key over a large number of fields



■■



Creating a column of a particular type that is very long



In order to run crashme you first need to make sure you have Perl installed

along with DBI/DBD modules for MySQL (for installation instructions, see

Chapter 10).

Change to the sql-bench directory (on source and binary installations, it is

/usr/local/mysql/sql-bench and on the RPM installation it is /usr/share/sqlbench) and type ./crash-me --config-file=/tmp/mysql.cnf. You will first see output similar to that shown in Listing 4.2.



Running ./crash-me 1.54 on 'MySQL 3.23.51 debug log'

I hope you didn't have anything important running on this server....

NOTE: You should be familiar with './crash-me —help' before continuing!

This test should not crash MySQL if it was distributed together with the

running MySQL version. If this is the case you can probably continue without

having to worry about destroying something.

Some of the tests you are about to execute may require a lot of memory. Your

tests WILL adversely affect system performance. It’s not uncommon that either

this crash-me test program, or the actual database back-end, will DIE with an



Listing 4.2



crash-me disclaimer message. (continues)



www.it-ebooks.info



56



Te s t i n g Yo u r M y S Q L I n s t a l l a t i o n



out-of-memory error. So might any other program on your system if it requests

more memory at the wrong time.

Note also that while crash-me tries to find limits for the database server it

will make a lot of queries that can’t be categorized as 'normal'. It's not

unlikely that crash-me finds some limit bug in your server so if you run this

test you have to be prepared that your server may die during it!

We, the creators of this utility, are not responsible in any way if your

database server unexpectedly crashes while this program tries to find the

limitations of your server. By accepting the following question with 'yes',

you agree to the above!

You have been warned!

Start test (yes/no) ?



Listing 4.2



crash-me disclaimer message. (continued)



At this, point if you really mean it, type yes and press the Enter key. As the test

progresses, you will see output similar to that shown in Listing 4.3.



Tables without primary key: yes

SELECT without FROM: yes

Select constants: yes

Select table_name.*: yes

Allows ' and " as string markers: yes

Double '' as ' in strings: yes

Multiple line strings: yes

" as identifier quote (ANSI SQL): error

` as identifier quote: yes

[] as identifier quote: no

Column alias: yes

Table alias: yes

Functions: yes

Group functions: yes

Group functions with distinct: yes

Group by: yes

Group by position: yes

Group by alias: yes

Group on unused column: yes

Order by: yes

Order by position: yes

Order by function: yes

Order by on unused column: yes



Listing 4.3



crashme results. (continues)



www.it-ebooks.info



Tài liệu bạn tìm kiếm đã sẵn sàng tải về

ERROR 2002: Can¡¯t connect to local MySQL server through socket ¡®/ tmp/ mysql. sock¡¯ ( 111)

Tải bản đầy đủ ngay(0 tr)

×