mysql笔记

我记录的一些mysql使用笔记

修改数据库,允许远程访问

1
2
3
4
5
6
7
8
use mysql;
update user set Host='%' where User='root';
(注:有一说是)
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;
flush privileges; # 清缓存

# 确认root的host是否是“%”
select host,user from user;

修改数据库

以wordpress修改网址为例(将siteurl字段值设置为

1
2
3
4
5
6
7
8
9
mysql -uroot -pJJ..**
use wordpress0;
select * from wp_options where option_name='siteurl';

update wp_options set option_value='http://blog.latelee.org' where option_name='siteurl';

select * from wp_options where option_name='home';

update wp_options set option_value='http://blog.latelee.org' where option_name='home';

查看数据库有哪些表:

1
show talbes;

查看数据库有哪些字段:

1
2
3
desc wp_comments;

describe wp_comments;

清空某一个表:

1
2
delete * from wp_comments;
truncate table wp_comments; # 注:测试时发现此语句无法执行

恢复禅道admin密码为123456

1
2
3
use zentao;
select * from zt_user where account='admin';
update zt_user set password='e10adc3949ba59abbe56e057f20f883e' where account='admin';

密码在zt_user表中,123456的md5值为e10adc3949ba59abbe56e057f20f883e。其它账号类似。

修改数据库root密码

1
2
3
use mysql;
update user set password=password('fuck123456') where user='root' and host='localhost';
flush privileges;
  • 本文作者:李迟
  • 版权声明:原创文章,版权归署名作者,转载建议注明出处(当然不注明亦可)。
  • 本文链接:/my-study/mysql-note.html