美文网首页
Ubuntu下数据库的远程连接

Ubuntu下数据库的远程连接

作者: 欧德朗 | 来源:发表于2020-01-09 10:41 被阅读0次

    2020-01-09
    首先查了一下指令
    就是这个CSDN

    mysql -u 用户名 -p密码 -h IP地址 -P 端口号 -D 数据库名字
    mysql -u root -proot -h 172.18.236.136 -P 3306 -D test
    记住-p后面的密码紧挨着-p不然会报错
    

    本地测试,但是报错

    chy:~$ mysql -u root -p123456 -h 192.168.24.144 -P 3306 -D mysql
    mysql: [Warning] Using a password on the command line interface can be insecure.
    ERROR 1130 (HY000): Host '192.168.24.123' is not allowed to connect to this MySQL server
    

    我自己本地还未安装MySQL Client,所以怀疑是没有安装客户端的问题,先安装一个.

    sudo apt install mysql-client-5.7

    发现已经安装好了.
    查一下原因
    这个讲的还不错
    是修改服务器端的host 不是修改本机的mysql,
    远程不能连接六步走

    1.登录root用户:
    mysql -u root -p
    2.use mysql;
    3.查看root用户的host相关情报
    select host from user where user='root';
    4.将host设置为通配符模式% Host设置“%”便可远程访问了,原来的host只能是localhost
    update user set host = '%' where user ='root';
    5.flush privileges;
    6.重启服务端

    server:~$ sudo /etc/init.d/mysql restart
    [sudo] password for mengfanbing-ubuntu: 
    [ ok ] Restarting mysql (via systemctl): mysql.service.
    

    重新远程连接,ok


    远程连接ok

    相关文章

      网友评论

          本文标题:Ubuntu下数据库的远程连接

          本文链接:https://www.haomeiwen.com/subject/pufyactx.html