忘记密码比较麻烦,太简单被攻破,太复杂记不住 嗨。。。。
重置密码的第一步就是跳过MySQL的密码认证过程,方法如下:
#vim /etc/my.cnf(注:windows下修改的是my.ini)
在文档内搜索mysqld定位到[mysqld]文本段:
/mysqld(在vim编辑状态下直接输入该命令可搜索文本内容)
在[mysqld]后面任意一行添加“skip-grant-tables”用来跳过密码验证的过程,如下图所示:
保存文档并退出
/etc/init.d/mysql restart (有些用户可能需要使用/etc/init.d/mysqld restart)
msyql
user mysql
update mysql.user set authentication_string=password('tanli!QAZ@WSX') where user='root';
flush privileges; #立即生效
drop user mysqlbackups@'%';
禁止、允许MySQL root用户远程访问权限
关闭MySQL root用户远程访问权限:
use mysql;
update user set host = "localhost" where user = "root" and host = "%";
flush privileges;
打开MySQL root用户的远程访问权限:
use mysql;
update user set host = "%" where user = "root";
flush privileges;
update user set host = '%' where user = 'cloudservice';
--创建名称为“testdb”数据库,并设定编码集为utf8
CREATE DATABASE IF NOT EXISTS testdb DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
--创建了一个名为:test 密码为:1234 的用户
create user 'test'@'localhost' identified by '1234';
--授予用户test通过外网IP对数据库“testdb”的全部权限
grant all privileges on 'testdb'.* to 'test'@'%' identified by '1234';
CREATE DATABASE IF NOT EXISTS cloudservicedb DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
create user 'cloudservice'@'localhost' identified by '123456789';
grant all privileges on 'cloudservicedb'.* to 'cloudservice'@'%' identified by '123456789';
grant create,alter,drop,select,insert,update,delete on cloudservicedb.* to cloudservice@'%';
SHOW DATABASES;
drop DATABASE please_read_me_vvv;
查看用户
select User,authentication_string,Host from user;
grant all privileges oncloudservicedb.* to 'cloudservice'@'%';