确实是个孩子谥 发表于 2024-9-11 23:31:10

MySQL数据库常用命令知识

1、开启MySQL服务
# /etc/init.d/mysqld start
# service mysqld start
# systemctl start mariadb
# systemctl start mysqld

2、检测端口是否运行
# lsof -i :3306
# netstat -ntl | grep 3306
3、MySQL设置密码或者修改密码
设置密码
#: mysqladmin -u root -p password 新密码
修改密码
> update user set password=password(‘新密码’) where user=‘root’; (mariadb)
mysql> ALTER user ‘root’@‘localhost’ IDENTIFIED BY ‘新密码’;(mysql8+)


4、查看当前数据库版本
#: mysql -V



5、创建用户并授权(mysql8+)
mysql> create user ‘用户名’@‘localhost’ identified by ‘123456’;
mysql> grant select,update on . to ‘用户名’@‘localhost’;



6、查看当前登录的用户
mysql> select user();
页: [1]
查看完整版本: MySQL数据库常用命令知识