zoukankan      html  css  js  c++  java
  • mysql8.0 远程数据库连接

    1:linux登录mysql

    [root@localhost mysql]# mysql -u root -p
    Enter password: 
    Welcome to the MySQL monitor.  Commands end with ; or g.
    Your MySQL connection id is 19
    Server version: 8.0.13 MySQL Community Server - GPL
    
    Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
    
    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> 
    
    

    2:查看user表,修改连接级别

    mysql> use mysql;
    Reading table information for completion of table and column names
    You can turn off this feature to get a quicker startup with -A
    
    Database changed
    mysql> select host,user from user;
    +-----------+------------------+
    | host      | user             |
    +-----------+------------------+
    | localhost | root             |
    | localhost | mysql.infoschema |
    | localhost | mysql.session    |
    | localhost | mysql.sys        |
    +-----------+------------------+
    4 rows in set (0.00 sec)
    
    可以看到,root用户的host值为localhost,这代表只能本地连接,将localhost修改为%
    update user set host='%' where user='root';
    

    3:可能你觉得到这一步就完事了,但是使用navicat连接测试时,会提示无法解析主机名相关的错误,这是mysql8的一些安全策略的问题,具体请左转google,解决办法如下

    ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'yourpassword';
    FLUSH PRIVILEGES;

    4:完毕

  • 相关阅读:
    专业术语-外文首字母组词的原词组
    SQL-常用数据类型
    phpStudy-FTP_Server插件安装使用教程
    SQL-有关数据库的提问
    phpStudy-在使用phpMyAdmin报404Error
    phpStudy-坑爹的数据库管理器-phpMyAdmin的默认用户名和密码
    软件需求说明书-关键字-中英文
    Vim-命令合集
    Git-实验报告
    Git-进阶-远程仓库的使用
  • 原文地址:https://www.cnblogs.com/wenxinphp/p/14797531.html
Copyright © 2011-2022 走看看