zoukankan      html  css  js  c++  java
  • mysql安装配置问题(linux下)

    1.安装后使用:mysql -u root -p 无法登录mysql

      错误提示:ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) 

      解决方法:修改mysql的密码

        (1).# /etc/init.d/mysql stop   先把mysql服务停掉

        (2).# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &    在启动mysql的时候,不启动grant-tables授权表,这样没有密码也能进入mysql

        (3).# mysql -u root mysql     使用这条命令直接可以登录mysql

        (4).# UPDATE user SET authentication_string=PASSWORD('newpassword') where USER='root';    修改你的mysql的root的密码

          (4.1). mysql5.7更改root密码时会出现:ERROR 1054 (42S22): Unknown column 'password' in 'field list' 这是因为mysql5.7开始,密码字段已经不是password了,而是authentication_string 

          (4.2). 修改密码时,注意不能直接写成 SET authentication_string='newpassword' 这样,这样修改密码是没用的,必须SET authentication_string=PASSWORD('newpassword'),修改的密码才会生效

        (5).# /etc/init.d/mysql restart    启动mysql,这是你用刚设置的密码进入mysql就可以了

    2.安装后的mysql只能本机root@localhost访问,其他网络是不能访问的,需要修改权限

      错误提示:ERROR 1130: Host ’192.168.1.21′ is not allowed to connect to this MySQL server

      解决方法:对mysql进行授权(指定某个ip可以访问、所有网络都可以访问)

        (1). mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'192.168.1.3' IDENTIFIED BY '123' WITH GRANT OPTION;    允许某个ip可以访问mysql

        (2).  mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;    任何主机都能访问mysql

  • 相关阅读:
    Java基础知识学习10-常用的API-01
    Java基础知识学习09-final、static关键字、匿名对象、内部类、修饰符、代码块
    Java基础知识学习08-构造方法
    前端网页学习01
    Java基础知识学习07-抽象类、接口、多态
    Java基础知识学习06-封装、继承
    Java基础知识学习05-类与对象
    Java基础知识学习04-自定义类、ArrayList集合
    Java基础知识学习03-数组
    1.9 向线程传递参数
  • 原文地址:https://www.cnblogs.com/zengguowang/p/5960338.html
Copyright © 2011-2022 走看看