use mysql #打开mysql数据库
2)将host设置为%表示任何ip都能连接mysql,当然您也可以将host指定为某个ip
update user set host='%' where user='root' and host='localhost'; flush privileges; #刷新权限表,使配置生效
然后我们就能远程连接我们的mysql了。
3)如果您想关闭远程连接,恢复mysql的默认设置(只能本地连接),您可以通过以下步骤操作:
use mysql #打开mysql数据库 update user set host='localhost' where user='root'; #将host设置为localhost表示只能本地连接mysql flush privileges; #刷新权限表,使配置生效 update user set password=password('123456') where User='root';#修改密码 flush privileges ; #刷新权限表,使配置生效
备注:您也可以添加一个用户名为yuancheng,密码为123456,权限为%(表示任意ip都能连接)的远程连接用户。命令参考如下:
grant all on *.* to 'yuancheng'@'%' identified by '123456'; flush privileges;
4)mysql排序时如果该字段是varchar怎么办?
2种办法:
1. order by 字段+0
2. order by cast(字段 as int)
6、批量修改字段数据
update t_comment SET avatar = replace(avatar, 'http', 'https');//替换 update t_log set message=concat("https",message);//前面追加
更多Mysql内容来自木庄网络博客
标签:Mysql
相关阅读 >>
更多相关阅读请进入《mysql》频道 >>

数据库系统概念 第6版
本书主要讲述了数据模型、基于对象的数据库和XML、数据存储和查询、事务管理、体系结构等方面的内容。