我在aws上启动了一个ec2示例,现在正在使用ubuntu。我能够在示例本身上连接到mysql(i、 e.mysql-h localhost-u root-p)
但是当我尝试从远程计算机连接时(例如mysql-h ipaddress-u remoteun-p)
ERROR 2003 (HY000): Can't connect to MySQL server on 'ipaddress' (61)
我已经更改了安全设置,允许所有ip地址连接到端口3306和端口22,并在示例上创建了一个可以从远程服务器访问mysql的用户
> CREATE USER 'tempuser'@'%' IDENTIFIED BY 'password';
> GRANT ALL PRIVILEGES ON *.* TO 'tempuser'@'%'
> WITH GRANT OPTION;
我尝试使用
> service mysqld restart
得到以下信息
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ===
Authentication is required to restart 'mysqld.service'.
身份验证为:ubuntu(ubuntu)密码:
我不确定默认密码是什么,当我输入mysql密码时
polkit-agent-helper-1: pam_authenticate failed: Authentication failure
==== AUTHENTICATION FAILED ===
Failed to restart mysqld.service: Access denied
See system logs and 'systemctl status mysqld.service' for details.
> systemctl status mysqld.service
mysqld.service
Loaded: not-found (Reason: No such file or directory)
Active: inactive (dead)
有人知道什么是默认密码,或者如何重新启动服务器以便我可以远程连接吗?
1条答案
按热度按时间0sgqnhkj1#
默认情况下禁用的是远程
root
进入。如果要启用此功能,请在本地运行此sql命令:GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION; FLUSH PRIVILEGES;
现在由于无法远程连接,您将不得不发表评论bind ip
线路输入my.cnf
通常存在的文件/etc/mysql/my.cnf
在unix/osx系统上。在某些情况下,文件的位置是/etc/mysql/mysql.conf.d/mysqld.cnf
).找到行:
bind-address = 127.0.0.1
加上#
在它前面保存并重启mysql,您应该能够远程连接到它。希望这有帮助!