0
点赞
收藏
分享

微信扫一扫

MySQL8远程连接不上的原因

攻城狮Chova 2021-09-21 阅读 51
我的博客

mysql8安装:

执行 ./bin/mysqld --defaults-file=xxx --initialize-insecure 初始化data目录

运行mysql8:

./bin/mysqld_safe --defaults-file=/home/xxx/mysql/my.cnf &

运行后netstat -anlp | grep mysql 发现mysqld进程使用的是unix domain socket,没使用tcp/tcp6,没监听端口,看配置文件里面有一行 --skip-grant-tables,看官方文档,如果开启了--skip-grant-tables默认启用--skip-networking,这样就不允许远程连接了,因为--skip-grant-tables不安全。
https://www.oreilly.com/library/view/mysql-8-cookbook/9781788395809/6ea03335-6ff2-4d4f-a008-48c8cf88fd01.xhtml#:~:text=In%20this%20method%2C%20you%20stop,to%20connect%20to%20the%20server.

Using --skip-grant-tables
In this method, you stop the server and start it by specifying --skip-grant-tables, which will not load the grant 
tables. You can connect to the server as root without a password and set the password. Since the server runs 
without grants, it is possible for users from other networks to connect to the server. So as of MySQL 8.0.3,
 --skip-grant-tables automatically enables --skip-networking, which does not allow remote connections:

关闭mysql

./bin/mysqladmin shutdown

举报

相关推荐

0 条评论