zoukankan      html  css  js  c++  java
  • MySQL远程连接root用户的坑

    # 踩坑场景

    Unable to access MySQL database remotely using root account. Any attempt to access MySQL database will result in error

    ERROR 1045 (28000): Access denied for user 'root'@'ip-address' (using password: YES)
    • user: root
    • password: 123456

    # 解决方案

    The above MySQL error message is a default behavior of the MySQL server to disallow a Root user to connect remotely as by default the Root user is allowed to connect to MySQL server on from localhost that is 127.0.0.1. The solution is to create a new admin user. The below SQL commands will create new user called admin and grant remote access:

    mysql> CREATE USER 'admin'@'%' IDENTIFIED BY '';
    Query OK, 0 rows affected (0.00 sec)
    
    mysql> GRANT ALL PRIVILEGES ON *.* TO 'admin'@'%' WITH GRANT OPTION;
    Query OK, 0 rows affected (0.00 sec)

     Alternative but not recommended solution is to grant remote MySQL access to root user:

    mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456';
    Query OK, 0 rows affected (0.00 sec)

     The above line will grant a privilege to the root user to connect remotely:

    $ mysql -h 10.8.9.76 -P 3306 -u root -p123456
    Welcome to the MariaDB monitor.  Commands end with ; or g.
    Your MySQL connection id is 41
    Server version: 5.5.43-0+deb8u1 (Debian)
    
    Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
    
    Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
    
    MySQL [(none)]> Bye
  • 相关阅读:
    熟悉常用的Linux操作
    Python基础之五星红旗
    类似于铁道部12306的城市选择框的实现
    使用Django操作数据库入门
    进程和线程
    线程、进程、携程理解
    CentOS6.8部署Python3.6.8的Django项目
    爬取妹子图片
    聚类算法之DBSCAN
    机器学习算法优缺点总结
  • 原文地址:https://www.cnblogs.com/kumata/p/13216449.html
Copyright © 2011-2022 走看看