mysql-重置密码--第四天

修改表名字:mysql> alter table user rename teacher;

mysql> create table userdb.teacher2 select * from teacher; 复制teacher表。
创建原表:
mysql> create table db4.teacher3
-> select * from userdb.teacher
-> order by uid desc
-> limit 5;

修改用户密码:
[root@web1 ~]# mysqladmin -hlocalhost -uroot -p password “654321”
Enter password: 123456

[root@web1 ~]# mysql -uroot -p654321
[root@web1 ~]# systemctl stop mysqld.service
[root@web1 ~]# vim /etc/my.cnf
[mysqld]
skip-grant-tables 不用密码直接登录
default-storage-engine=myisam
secure_file_priv="/mydata"
#validate_password_policy=0
#validate_password_length=6
[root@web1 ~]# systemctl start mysqld
[root@web1 ~]# mysql
mysql> select user,host,authentication_string from mysql.user;
mysql> update mysql.user
-> set authentication_string=password
-> (“abc123”) where host=“localhost” and user=“root”;
mysql> flush privileges;
[root@web1 ~]# systemctl stop mysqld.service
[root@web1 ~]# vim /etc/my.cnf
[mysqld]
#skip-grant-tables
default-storage-engine=myisam
secure_file_priv="/mydata"
validate_password_policy=0
validate_password_length=6
[root@web1 ~]# systemctl start mysqld
[root@web1 ~]# mysql -uroot -abc123

授权命令的语法格式:
mysql>grant 权限列表 on 数据库名 to 用户名@“客户端地址” identified by “密码” with grant options;
mysql> grant all on . to plj@“localhost” identified by “123456”; 授权所有用户都可登录。
[root@client ~]# mysql -uplj -p123456
mysql> show grants; 登录用户对表的权限。
mysql> grant select,insert,update on userdb.* to yaya@“192.168.4.254”
-> identified by “123456”;

mysql> grant all on . to
-> root@“192.168.4.5” identified by
-> “123456” with grant option;
[root@proxy ~]# mysql -h192.168.4.100 -ustudent -p123456
mysql> grant select,update(name) on userdb.teacher to student identified by “123456”;

user 已有的授权用户和访问权限
db 记录授权用户对本机库的访问权限
tables_priv 记录授权用户对本机表的访问权限
columns_priv 记录授权用户对本机表中字段的访问权限

mysql> grant all on . to
-> root@“192.168.4.5” identified by
-> “123456” with grant option;

user 已有的授权用户和访问权限
db 记录授权用户对本机库的访问权限
tables_priv 记录授权用户对本机表的访问权限

columns_priv 记录授权用户对本机表中字段的访问权限。

mysql> select user,host from mysql.user;
mysql> select * from mysql.user where user=“student” and host="%"\G;
mysql> show grants for ‘root’@‘192.168.4.13’; 查看权限
mysql> revoke delete,insert on . from roo@“192.168.4.100”; 删除权限
mysql> revoke select on . from roo@“192.168.4.100”; 删除select 权限。
mysql> revoke all on . from roo@“192.168.4.100”; 删除所有权限。

安装mysql图形管理工具phpmyadmin
rpm -q php php-mysql httpd
systemctl start httpd
systemctl enable httpd
tar -zxvf phpMyAdmin-2.11.11-all-languages.tar.gz -C /var/www/html/
cd /var/www/html
mv f phpMyAdmin-2.11.11-all-languages phpmyadmin
cd phpmyadmin
cp config.sample.inc.php config.inc.php

[root@client phpmyadmin]# vim config.inc.php
17 $cfg[‘blowfish_secret’] = ‘plj123’; /* YOU MUST FILL IN THIS FOR COOKIE AUTH ! */
32 c f g [ ′ S e r v e r s ′ ] [ cfg['Servers'][ cfg[Servers][i][‘host’] = ‘localhost’;
[root@client phpmyadmin]# systemctl restart httpd
http://192.168.4.5/phpmyadmin/

数据库管理重置授权用户的登录密码。
set password for 用户名@‘用户端地址’=password(“新密码”);

[root@proxy phpmyadmin]# vim config.inc.php
17 $cfg[‘blowfish_secret’] = ‘plj123’;
31 c f g [ ′ S e r v e r s ′ ] [ cfg['Servers'][ cfg[Servers][i][‘host’] = ‘localhost’

http://192.168.4.5/phpmyadmin/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值