Mysql 常用命令

大纲

preview

命令执行

事务

START TRANSACTION; //开启事务

UPDATE `Users` SET AccountId=0 WHERE AccountId is null

COMMIT; // 提交

ROLLBACK; // 回滚

常见问题

Q1. 允许远程登录

# root 登录
mysql -u root -p

# 切换数据库
mysql> use mysql
Database changed
#查看数据库当前有访问权限的信息
mysql> SELECT User, Password, Host FROM user;
+------+-------------------------------------------+-------------------------+
| user | password                                  | host                    |
+------+-------------------------------------------+-------------------------+
| root | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 | localhost               |
| root | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 | iz2zecn05w4ymvtjyqf3fkz |
| root | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 | 127.0.0.1               |
+------+-------------------------------------------+-------------------------+

# 设置访问权限
# *.*代表所有资源所有权限
# 'root'@'%' 其中root代表账户名,%代表所有的访问地址
# 'root',这个root是指访问密码
# WITH GRANT OPTION 允许级联授权
myql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;

# 刷新访问权限表
myql>FLUSH PRIVILEGES;
posted @ 2022-08-27 15:52  renzhsh  阅读(14)  评论(0编辑  收藏  举报