root密码忘记,重置mysql的root密码:
一、修改mysql的配置文件my.cnf
1.在[mysqld]的段中加上一句:skip-grant-tables
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
skip-name-resolve
skip-grant-tables
保存并且退出vi。
(或执行 mysqld_safe --skip-grant-tables &)
2.重新启动mysqld
# /etc/init.d/mysqld restart
Stopping MySQL: [ OK ]
Starting MySQL: [ OK ]
3.登录并修改MySQL的root密码
# /usr/bin/mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3 to server version: 3.23.56
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> use mysql ;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> UPDATE user SET Password = password ( 'new-password' ) WHERE User = 'root' ;
Query OK, 0 rows affected (0.00 sec)
Rows matched: 2 Changed: 0 Warnings: 0
mysql> flush privileges ;
Query OK, 0 rows affected (0.01 sec)
mysql> quit
Bye
4.将MySQL的登录设置修改回来
# vi /etc/my.cnf
将刚才在[mysqld]的段中加上的skip-grant-tables删除
保存并且退出vi。
5.重新启动mysqld
# /etc/init.d/mysqld restart
Stopping MySQL: [ OK ]
Starting MySQL: [ OK ]
二、
停止mysql服务
/etc/init.d/mysqld stop
sudo mysqld_safe --skip-grant-table&
mysql
use mysql;
update user set password = password('yourpasswd') where user = 'root';
flush privileges;
重启下mysql服务即可重新用新密码登录
/etc/init.d/mysqld restart
允许远程连接mysql
通过navicat连接MySQL的时候发生的这个错误
ERROR 1130: Host ***.***.***.*** is not allowed to connect to this MySQL server
说明所连接的用户帐号没有远程连接的权限,只能在本机(localhost)登录。
需更改 MySQL 数据库里的 user表里的 host项
把localhost改称%
一、
登陆到MySQL ,首先 use MySQL;
按照别人提供的方式update的时候,出现错误。
MySQL> update user set host='%' where user = 'root';
ERROR 1062 (23000): Duplicate entry '%-root' for key 'PRIMARY'
然后查看了下数据库的host信息如下:
MySQL> select host from user where user = 'root';
+-----------------------+
| host |
+-----------------------+
| % |
| 127.0.0.1 |
| localhost.localdomain |
+-----------------------+
3 rows in set (0.00 sec)
host已经有了%这个值,所以直接运行命令:
MySQL>flush privileges;
二、
mysql> grant all privileges on *.* to 'root'@'%' with grant option;
Query OK, 0 rows affected (0.02 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> selectuser.host from user;
+-----------+--------------+
| user| host|
+-----------+--------------+
| root| %|
| root| 127.0.0.1|
| repl_user | 192.168.1.52 |
+-----------+--------------+
3 rows in set (0.00 sec)
允许指定IP访问mysql
mysql> grant all privileges on *.* to 'root'@***.***.***.**** identified by '123456';
QueryOK, 0 rows affected (0.00 sec)
相关推荐
centos 6.5配置mysql5.5
CentOS6.5 一键安装 Mysql5.6 包含安装包
主要介绍了CentOS 8 安装 MySql并设置允许远程连接的方法,本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下
如何升级CentOS 6.5下的MySQL
Centos6.5镜像文件 Linux。。
centos 6.5 telnet 客户端 安装文件 rpm包 centos 6.5 telnet 服务端 安装文件 rpm包 http://vault.centos.org/6.5/os/x86_64/Packages/ 从官网下载亲测可以用
centOS 6.5 安装 mysql-5.7.22-linux-glibc2.12-x86_64.tar.gz
下面将详细介绍如何使用 VMware 创建虚拟机并安装 CentOS6.5 操作系统。 步骤一:创建 CentOS6.5 虚拟机 1. 打开 VMware 软件,点击“文件”菜单,然后选择“新建虚拟机”。 2. 在“新建虚拟机向导”中,选择...
讲解centos上安装mysql的操作过程,主要为操作过程中执行的相关配置,方便大家查看使用,如果有错误之处,还请大家留意指正。
CentOS6.5的64位镜像文件iso。CentOS是基于linux内核而扩展的操作系统。
E3:用mysql安装包在CentOS6.5系统下安装和配置mysql.docx
Centos6.5下安装Mysql5.7+的脚本及安装手册。 安装包需要从网上下载,我测试的安装包为mysql-5.7.10-linux-glibc2.5-x86_64.tar.gz,500多M,上传不了。注意:必须是二进制安装版的,不能是rpm或源码版的。 经我测试...
Linux centos 6.5 官网版本Bt下载种子
Centos6.5下安装Oracle 11g.docxCentos6.5下安装Oracle 11g.docx
Centos 6.5下C连接MySQL测试
CentOS 6.5 的 软件源很多官方已经停止维护,该文件包内配置好的yum源是可以正常使用的。将原/etc/yum.repos.d/目录下原来的 .repo 备份, 然后把本文件包内的repo文件复制过去, yum clean all 后,再 yum ...
centos6.5安装mysql5版本,这个是介绍博文地址http://t.csdn.cn/OePCe。
CentOS6.5安装MySQL5.7.22安装方法,实际中使用,真实可用
linux下centos6.5静默安装oracle 12c(图形化安装教程)
Centos 6.5 Oracle 11G R2 安装文档