zoukankan      html  css  js  c++  java
  • Mysql初始化root密码和允许远程访问

    mysql默认root用户没有密码,输入mysql –u root 进入mysql

    1、初始化root密码

    进入mysql数据库

    mysql>update user set password=PASSWORD('123456') where User='root';

    2、允许mysql远程访问,有以下几中方式

    如果不允许远程访问,会报如下的错误:

    ERROR 1130 (HY000): Host ‘1.2.3.4’ is not allowed to connect to this MySQL server

    (1)、Change mysql config

    vim /etc/mysql/my.cnf

    Comment out following lines.

    #bind-address           = 127.0.0.1
    #skip-networking

    If you do not find skip-networking line, add it and comment out it.

    Restart mysql server.

    /etc/init.d/mysql restart

    (2)、Change GRANT privilege

    Run a command like below to access from all machines. (Replace USERNAME and PASSWORD by your credentials.)

    mysql> GRANT ALL PRIVILEGES ON *.* TO 'USERNAME'@'%' IDENTIFIED BY 'PASSWORD' WITH GRANT OPTION;

    Run a command like below to give access from specific IP. (Replace USERNAME and PASSWORD by your credentials.)

    mysql> GRANT ALL PRIVILEGES ON *.* TO 'USERNAME'@'1.2.3.4' IDENTIFIED BY 'PASSWORD' WITH GRANT OPTION;

    Finally, you may also need to run:

    mysql> FLUSH PRIVILEGES;
  • 相关阅读:
    Django中的分页操作、form校验工具
    Django之form表单操作
    手写版本orm
    mysql注入问题
    MySQL基本操作
    初识数据库
    进程池、线程池
    信号量
    event事件
    死锁
  • 原文地址:https://www.cnblogs.com/ahang/p/6805921.html
Copyright © 2011-2022 走看看