验证环境:

[root@~~/]# rpm -qa | grep mysqlmysql-5.6.28-1.el6.x86_64[root@~~/]# lsb_release -aLSB Version:  :core-4.1-amd64:core-4.1-noarchDistributor ID: CentOSDescription:  CentOS Linux release 7.2.1511 (Core)Release:    7.2.1511Codename:    Core[root@~~/]# uname -r3.10.0-327.22.2.el7.x86_64

因为在重新设置mysql的root密码的期间,MySQL数据库完全出于没有密码保护的状态下,其他的用户也可以任意地登录和修改MySQL的信息。可以采用将MySQL对外的端口封闭,并且停止Apache以及所有的用户进程的方法实现服务器的准安全状态。最安全的状态是到服务器的Console上面操作,并且拔掉网线。

修改MySQL的登录设置:

在[mysqld]的段中加上一句:skip-grant-tables

[root@~~/]# vi /etc/my.cnf
[mysqld] datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock skip-grant-tables 

重新启动mysqld

[root@~~/]# /etc/init.d/mysqld restart Stopping MySQL: [ OK ] Starting MySQL: [ OK ]
[root@~~/]# mysqlWelcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 1Server version: 5.6.28-log Source distributionCopyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql> use mysql;mysql> update user set password=password("test") where user='root';mysql> flush privileges;mysql> exit; Bye

将刚才在[mysqld]的段中加上的skip-grant-tables删除,保存并且退出vi;

[root@~~/]# vi /etc/my.cnf

再次重新启动mysqld

[root@~~/]# /etc/init.d/mysqld restart Stopping MySQL: [ OK ] Starting MySQL: [ OK ]

如果外网不能访问数据库,可以进行如下操作:

[root@~~/]# firewall-cmd --permanent --zone=public --add-port=3306/tcp success[root@~~/]# firewall-cmd --reloadsuccess

更多相关文章

  1. 【阿里云镜像】切换阿里巴巴开源镜像站镜像——Fedora镜像
  2. 【阿里云镜像】使用阿里巴巴DNS镜像源——DNS配置教程
  3. 【阿里云镜像】切换阿里巴巴开源镜像站镜像——Debian镜像
  4. android中HttpURLConnection调用getResponseCode()时崩溃 解决方
  5. Android空引用问题的解决方法——on a null object reference
  6. android读取assets大于1M文件的解决方法
  7. 几个Android小错误解决方法
  8. CheckBox android:paddingLeft 不兼容问题解决方法
  9. 淘宝(阿里百川)手机客户端开发日记第一篇 android 主框架搭建(三

随机推荐

  1. Android(六): What Android Is
  2. 清除app数据等同于设置中的清除数据
  3. Android 弹球游戏
  4. 单选按钮(RadioButton)和复选框(CheckBox)的
  5. 不使用布局文件,代码中自定义界面
  6. Android 设置声音时出现按键音
  7. Android7.0中文文档(API) -- Switch
  8. Android Studio入门小例子
  9. Ubuntu12.04安装JDK6
  10. Android中查看网卡设备信息