天天看點

linux指令之MySQLskip-grant-tables

版權聲明:本文為部落客原創文章,未經部落客允許不得轉載。 https://blog.csdn.net/w1lgy/article/details/80388716

yum search mysql

sudo yum remove mariadb-libs.x86_64

tmp下

wget

https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm

sudo yum localinstall mysql57-community-release-el7-11.noarch.rpm

sudo yum install mysql-community-server

sudo service mysqld start/restart/stop/

cat /var/log/mysqld.log|grep password

密碼:&#g,MU8vc!

YqKD0*eLh3ys

mysql> set global validate_password_policy=0;

mysql> set global validate_password_length=1;

重置密碼

SET PASSWORD = PASSWORD(‘123456’);

mysql -uroot -p

&#g,MU8vc!

遠端

MySQL -h127.0.0.1 -uroot -p

use mysql;

show tables;

select Host,User from user \G;

update user set host=’%’ where Host = “localhost” and User = “root”;

flush privileges;

set global general_log_file=”/tmp/general.log”;

set global genenral_log=on;

set global validate_password_policy=0;

set global validate_password_length=1;

create user ‘imooc’@’%’ identified by ‘123456’;

賦予權限

grant all privileges on . to ‘imooc’@’%’ identified by ‘123456’ with grant option;

部分權限

grant select,insert,update, delete on . to ‘imooc’@’%’ identified by ‘123456’ with grant option;

回收權限

revoke all privileges on . from imooc;

修改root密碼:

sudo vim /etc/my.cnf

在最後添加一行(跳過授權表的驗證)

skip-grant-tables

重新開機服務

sudo service mysqld restart

不用輸入密碼就能進入資料庫了

update user set authentication_string=password(‘456789’) where user=’root’;

去掉最後添加一行(跳過授權表的驗證)

skip-grant-tables