Erlang:通过Erlang-MySQL-Driver连接到MySQL时发生超时错误

brjng4g3  于 2022-12-08  发布在  Erlang
关注(0)|答案(1)|浏览(153)

After solving compiling errors, another issue came out in the database connection test.
The Erl-MySQL-Driver is cloned from git and re-compiled under the local environment.
Then I entered the Erlang shell and tried to connect to my database (pls ignore the unsafe password..), then the ERROR REPORT showed a connection time-out error.

[root@perryhost ~]#erl

Erlang/OTP 24 [erts-12.1.5] [source] [64-bit] [smp:2:2] [ds:2:2:10] [async-threads:1]

Eshell V12.1.5  (abort with ^G)
1> mysql:start_link("test", "localhost", "3306", "root", "123456", "sdzmmo").
=ERROR REPORT==== 9-Dec-2021::23:24:09.886253 ===
Error in process <0.85.0> with exit value:
{function_clause,[{mysql_recv,start_link,
                              ["localhost","3306",#Fun<mysql.0.19863791>,
                               <0.85.0>],
                              [{file,"src/lib/mysql/mysql_recv.erl"},
                               {line,67}]},
                  {mysql_conn,init,9,
                              [{file,"src/lib/mysql/mysql_conn.erl"},
                               {line,315}]}]}

mysql:503: failed starting first MySQL connection handler, exiting
{error,{error,"timed out"}}

As the stack above mentioned, this cmd failed to start the first MySQL connection handler. Does this info mean that my DB is not using a proper configuration? Or the Erlang drive is quoted incorrectly?
All config tags in my.cnf are listed below:

[mysqld]

# innodb_buffer_pool_size = 128M

# log_bin

# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M

datadir=/var/lib/mysql

#socket=/var/lib/mysql/mysql.sock

symbolic-links=0

log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

character-set-server=utf8
collation-server=utf8_general_ci

[client]
default-character-set=utf8

Installed MySQL version is:

[root@ perryhost ~]# mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.36 MySQL Community Server (GPL)

Copyright (c) 2000, 2021, Oracle and/or its affiliates.

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>
voj3qocg

voj3qocg1#

mysql_recv:start_link的第一行如下所示:

start_link(Host, Port, LogFun, Parent) when is_list(Host), is_integer(Port) ->

也就是说,它需要以整数形式传递端口号。在调用函数时,请尝试使用3306而不是"3306"

相关问题