RELATEED CONSULTING
相关咨询
选择下列产品马上在线沟通
服务时间:8:30-17:00
你可能遇到了下面的问题
关闭右侧工具栏

新闻中心

这里有您想知道的互联网营销解决方案
数据库基本使用

1.登录和退出MySQL服务器
mysql -h主机名 -u用户名 -p密码 -e"sql 命令"
例1:mysql -uroot -p123456 #root用户,密码123456登录数据库。
例2:mysql -uroot -p123456 -e "desc mysql.user" #root用户,密码123456登录并查看user表结构。
例3:mysql -uroot -p123456 mysql #root用户,密码123456登录并直接进入mysql数据库。
2.新建普通用户:
2.1使用create user语句创建新用户。
例: create user zhangsan@localhost identified by "132456"; #创建用户张三,指定密码为123456.
例: create user zhangsan@"%" identified by "123456"; #创建用户张三,指定密码为123456.
2.2使用grant 语句创建用户:
例:grant all on . to zhangsan@localhost identified by "123456"; #创建张三用户并授予对所有数据库的所有表的所有权限。
select from mysql.user where user='zhangsan'\G; #查看zhangsan用户的信息,权限都为 y。
3.删除普通用户:
3.1 例:drop mysql.user zhangsan@localhost; #删除用户zhangsan;
3.2 例:delete from mysql.user where user='zhangsan'; #删除用户zhangsan。
4.root用户修改自己密码:
4.1 mysqladmin -uroot -p123456 password '654321' #命令行修改,-p指定旧密码,引号里为新密码。
4.2 update mysql.user set password=password('123456') where user='root'; flush privileges; #把root用户密码该为123456;刷新权限表。
4.3 set password=password('654321'); #修改root用户密码为123456;
5.root用户修改普通用户密码:
5.1 set password for zhangsan@localhost = password('123456'); #修改zhangsan密码为123456.
5.2 update mysql.user set password=password('123456') where user='zhangsan';flush privileges; #修改zhangsan用户的密码为123456;刷新权限表。
5.3 grant usage on
.* to zhangsan@localhost identified by '123456'; #修改zhangsan用户密码为123456;

10年积累的成都网站设计、成都做网站经验,可以快速应对客户对网站的新想法和需求。提供各种问题对应的解决方案。让选择我们的客户得到更好、更有力的网络服务。我虽然不认识你,你也不认识我。但先网站制作后付款的网站建设流程,更有柳林免费网站建设让你可以放心的选择与我们合作。

  1. 普通用户修改密码:
    6.1 set password=password('123456'); #使用普通用户登录数据库,执行命令。
    7.root用户密码丢失的解决办法:
    7.1 修改配置文件/etc/my.cnf 在【mysql】下添加 skip-grant-tables
    7.2 systemctl restart mariadb #重启服务
    7.3 mysql #登录数据库
    7.4 set password=password('123456'); #修改密码
    7.5 vim /etc/my.cnf 注释掉 #skip-grant-tables
    7.6 systemctl restart mariadb #重启服务
    8.localhost 为本地登录 “%” 为远程登录

网页标题:数据库基本使用
网站链接:http://scyingshan.cn/article/jdpsjd.html