1、开启MySQL服务
[root@localhost ~]# /etc/init.d/mysqld start
[root@localhost ~]# service mysqld start
[root@localhost ~]# systemctl start mariadb
[root@localhost ~]# systemctl start mysqld
2、检测端口是否运行
[root@localhost ~]# lsof -i :3306
[root@localhost ~]# netstat -ntl | grep 3306
3、MySQL设置密码或者修改密码
设置密码
[root@ ~]#: mysqladmin -u root -p password 新密码
修改密码
[mysql]> update user set password=password(‘新密码’) where user=‘root’; (mariadb)
mysql> ALTER user ‘root’@‘localhost’ IDENTIFIED BY ‘新密码’;(mysql8+)
4、查看当前数据库版本
[root@ ~]#: mysql -V
5、创建用户并授权(mysql8+)
mysql> create user ‘用户名’@‘localhost’ identified by ‘123456’;
mysql> grant select,update on . to ‘用户名’@‘localhost’;
6、查看当前登录的用户
mysql> select user();