【问题标题】:what is proper mysql database connection string什么是正确的mysql数据库连接字符串
【发布时间】:2023-03-03 04:27:01
【问题描述】:

我正在使用以下连接字符串:

mysql://root:root@newserver/metro

在哪里

用户名:root

密码:root

服务器:新服务器

数据库:地铁

出现以下错误:

2017/08/19 06:10:02 网络“newserver”的默认地址未知

这里是mysql服务器日志:

重定向到 /bin/systemctl status mysqld.service ● mysqld.service - MySQL 社区服务器 已加载:已加载(/usr/lib/systemd/system/mysqld.service;已启用;供应商预设:已禁用) 活跃:自世界标准时间 2017 年 8 月 18 日星期五 17:14:59 起活跃(运行); 12 小时前 进程:23510 ExecStartPost=/usr/bin/mysql-systemd-start post (code=exited, status=0/SUCCESS) 进程:23447 ExecStartPre=/usr/bin/mysql-systemd-start pre (code=exited, status=0/SUCCESS) 主 PID:23509(mysqld_safe) CGroup:/system.slice/mysqld.service ├─23509 /bin/sh /usr/bin/mysqld_safe --basedir=/usr └─23676 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --log-error=/var/log/ mysqld.log --pid-file=/var/run/...

8 月 18 日 17:14:58 newserver mysql-systemd-start[23447]:通过在 http://shop.mysql.com 购买支持/许可证来支持 MySQL 8 月 18 日 17:14:58 newserver mysql-systemd-start[23447]:注意:未创建新的默认配置文件。 8 月 18 日 17:14:58 newserver mysql-systemd-start[23447]:请确保您的配置文件是最新的 8 月 18 日 17:14:58 newserver mysql-systemd-start[23447]:警告:系统上存在默认配置文件 /etc/my.cnf 8 月 18 日 17:14:58 newserver mysql-systemd-start[23447]: MySQL 服务器默认读取该文件 8 月 18 日 17:14:58 newserver mysql-systemd-start[23447]:如果你不想使用这个,要么删除它,要么使用 8 月 18 日 17:14:58 newserver mysql-systemd-start[23447]:启动服务器时 mysqld_safe 的 --defaults-file 参数 8 月 18 日 17:14:58 newserver mysqld_safe[23509]: 170818 17:14:58 mysqld_safe 记录到“/var/log/mysqld.log”。 8 月 18 日 17:14:58 newserver mysqld_safe[23509]: 170818 17:14:58 mysqld_safe 使用来自 /var/lib/mysql 的数据库启动 mysqld 守护进程 8 月 18 日 17:14:59 newserver systemd[1]:启动 MySQL Community Server。

以下是 /etc/hosts 的内容

172.31.43.60 新服务器

此配置在单机上,我正在尝试使用 golang 程序访问。

这是相同的网址:

https://github.com/utronframework/tutorials/blob/master/create_todo_list_application_with_utron.md

文件名为 config/app.json

这是我的 app.json 文件

{
    "app_name": "utron web app",
    "base_url": "http://localhost:8090",
    "port": 8090,
    "verbose": false,
    "static_dir": "static",
    "view_dir": "views",
    "database": "mysql",
    "database_conn": "mysql://root:root@newserver/metro",
    "automigrate": true

}

请推荐

【问题讨论】:

  • 你试图从哪里连接到mysql服务器?
  • 我刚刚更新了我的查询...请建议
  • 你试过mysql://root:root@172.31.43.60/metro
  • 是的,试过了。还是一样的错误

标签: mysql go


【解决方案1】:

我对Go一无所知,但我可以read the documentation,这表明你需要使用这个:

root:root@tcp(newserver)/metro

或者可能:

mysql://root:root@tcp(newserver)/metro

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-07-02
    • 1970-01-01
    • 2016-03-18
    • 1970-01-01
    • 1970-01-01
    • 2020-05-20
    • 2011-05-16
    • 1970-01-01
    相关资源
    最近更新 更多