操作
查看mysql运行状态
systemctl status mysqld
停止mysql
systemctl stop mysqld
启动mysql
systemctl start mysqld
重启mysql
systemctl restart mysqld
开启mysql开机自启动
systemctl enable mysqld
关闭mysql开机自启动
systemctl disable mysqld
查看具体的报错日志
只看ERROR的
cat /var/log/mysqld.log | grep ERROR
mysql首次修改密码
查看默认密码
grep "password" /var/log/mysqld.log
进入到mysql里面
mysql -uroot -p
设置密码强度和长度的限制
set global validate_password_policy=LOW;
set global validate_password_length=17;
修改密码
alter user 'root'@'localhost' identified by '0123456789_123456';
mysql忘记密码修改
修改 /etc/my.conf
新增 skip_grant_tables
vim /etc/my.conf
重启一下mysql
systemctl restart mysqld
进入到mysql里面
mysql -uroot -p
不用输入密码 直接回车
修改密码
use mysql;
update user set authentication_string= password("root") where user='root';
去除 skip_grant_tables
重启 systemctl restart mysqld