最新消息:20181230 VPS服务器已从Linode换到腾讯云香港,主题仍用朋友推荐的大前端D8

【已解决】阿里云RDS的Mysql数据库连接不上没反应

MySQL crifan 164浏览 0评论

登录阿里云的ECS服务器中,用mysql命令行去访问阿里云RDS的mysql数据库,

之前是可以连接的,但是现在无法连接,没有反应(也不是密码错误之类的):

去阿里云控制台看看,好像也没问题啊:

阿里云 RDS mysql 命令行 无响应

使用限制_快速入门MySQL版_云数据库 RDS 版-阿里云

RDS MySQL 管理长时间运行查询_MYSQL使用_技术运维问题_云数据库 RDS 版-阿里云

阿里云服务器MySQL无法连接问题解决纪实 – CSDN博客

阿里云配置MYSQL远程连接 – CSDN博客

结果最后用:

mysql -h xxx.mysql.rds.aliyuncs.com -u root -p

再输入密码,是可以登录mysql的:

然后去看看help的语法:

[root@naturling-general-01 mysqlQa]# mysql –help

mysql  Ver 15.1 Distrib 5.5.56-MariaDB, for Linux (x86_64) using readline 5.1

Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.

Usage: mysql [OPTIONS] [database]

Default options are read from the following files in the given order:

/etc/mysql/my.cnf /etc/my.cnf ~/.my.cnf

The following groups are read: mysql client client-server client-mariadb

The following options may be given as the first argument:

<span style="font-family: Monaco; font-size: 12px; color: rgb(51, 51, 51);"–<print-defaults        Print the program argument list and exit.

<span style="font-family: Monaco; font-size: 12px; color: rgb(51, 51, 51);"–<no-defaults           Don't read default options from any option file.

<span style="font-family: Monaco; font-size: 12px; color: rgb(51, 51, 51);"–<defaults-file=#       Only read default options from the given file #.

<span style="font-family: Monaco; font-size: 12px; color: rgb(51, 51, 51);"–<defaults-extra-file=# Read this file after the global files are read.

  -?, –help          Display this help and exit.

  -I, –help          Synonym for -?

  –binary-mode       By default, ASCII ‘\0’ is disallowed and ‘\r\n’ is

                      translated to ‘\n’. This switch turns off both features,

                      and also turns off parsing of all clientcommands except

                      \C and DELIMITER, in non-interactive mode (for input

                      piped to mysql or loaded using the ‘source’ command).

                      This is necessary when processing output from mysqlbinlog

                      that may contain blobs.

Variables (–variable-name=value)

and boolean options {FALSE|TRUE}  Value (after reading options)

<span style="font-family: Monaco; font-size: 12px; color: rgb(51, 51, 51);"–<——————————- —————————————-

abort-source-on-error             FALSE

auto-rehash                       TRUE

plugin-dir                        (No default value)

default-auth                      (No default value)

binary-mode                       FALSE

发现是:

-B是

  -B, –batch         Don’t use history file. Disable interactive behavior.

                      (Enables –silent.)

的含义,不是制定对应的use someDb的意思。

所以去找找,mysql中,命令行参数,如何指定db:

mysql pass use database

mysql command line use database

mysql select  database via command

MYSQL – select database – Stack Overflow

好像是-p参数,去看看help的解释

  -p, –password[=name]

                      Password to use when connecting to server. If password is

                      not given it’s asked from the tty.

发现看错了,而是:

直接在mysql的命令行的最后,加上数据库的名字,即可:

mysql -u xxx -p databaseName

-p只是密码的意思。

【总结】

看来是之前参考mysqldump中的:

-uroot

参数给myql是有问题的

-》改为:

-u root

即可。

完整命令行是:

(1)只登录,不选择指定哪个数据库

mysql -h xx-xxx.mysql.rds.aliyuncs.com -u root -p

(2)指定使用具体的数据库:

mysql -h xx-xxx.mysql.rds.aliyuncs.com -u root -p dbname

转载请注明:在路上 » 【已解决】阿里云RDS的Mysql数据库连接不上没反应

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
55 queries in 0.110 seconds, using 10.09MB memory