重温MySQL

Posted 0bug

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了重温MySQL相关的知识,希望对你有一定的参考价值。

登录

mysql -uroot -p123456

查询当前用户

 select user();

技术分享图片

不执行某条语句

\\c

技术分享图片

查看帮助信息

 help create user;

创建用户

create user ‘0bug‘@‘%‘ identified by ‘123456‘;  # 所有人都能登录

create user ‘user192‘@‘192.168.32.*‘ identified by ‘123456‘;  # 指定网段的人可以登录

链接mysql

mysql -u0bug -p123456 -h192.168.11.25

技术分享图片

为用户授权

all privileges可简写成all ,赋给0bug所有库下的所有表权限

 grant all privileges on *.* to ‘0bug‘@‘%‘;

flush privileges;  # 刷新

技术分享图片

创建用户并授权(两部合一步)

grant all on *.* to ‘lcg‘@‘%‘ identified by ‘123456‘;

技术分享图片

修改用户登录密码

mysqladmin -uroot -p123456 password 123

技术分享图片

杀死mysql进程

tasklist |findstr mysql  # 查看进程

tskill mysqld  # 通过进程名杀死进程

taskkill -f /PID 12532  # 通过进程pid杀死进程

技术分享图片

忘记密码后修改密码方案

杀死mysqld--->启动mysqld跳过授权表,登录root用户后更新密码

tasklist |findstr mysql

taskkill -f /PID 10176

另起终端登录root用户更改密码:
mysql -uroot -p

update mysql.user set password=password(‘123123‘) where user=‘root‘ and host=‘localhost‘;

flush privileges;

技术分享图片

技术分享图片

 

以上是关于重温MySQL的主要内容,如果未能解决你的问题,请参考以下文章

linux中怎么查看mysql数据库版本

从mysql的片段中加载ListView

主从复制 读写分离 原理重温

连接MySQL出现错误:ERROR 1045 (28000): Access denied for user ‘root‘@‘localhost‘ (using password: YES)(代码片段

使用 json rereiver php mysql 在片段中填充列表视图

复习 | 重温jQuery和Zepto的API