linux指令之MySQL

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;

flush privileges;

回收权限
revoke all privileges on . from imooc;
flush privileges;

修改root密码:

sudo vim /etc/my.cnf
在最后添加一行(跳过授权表的验证)
skip-grant-tables
重启服务
sudo service mysqld restart

不用输入密码就能进入数据库了

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

flush privileges;

sudo vim /etc/my.cnf
去掉最后添加一行(跳过授权表的验证)

skip-grant-tables

重启服务
sudo service mysqld restart

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值