一、MySQL服务的管理
启动 systemctl start mysqld
停止 systemctl stop mysqld
重启 systemctl restart mysqld
查看mysqld的状态 systemctl status mysqld
随机启动 systemctl enable mysqld
禁止随机启动 systemctl disable mysqld
二、进程和端口的查看
ps -efww | grep mysqld
netstat -antp | grep mysql
三、mysql的文件路径
/var/lib/mysql/ 数据库的存放位置
/etc/my.cnf mysql的主配置文件
/etc/my.cnf.d/ mysql的附加配置文件的路径
四、查看默认密码
cat /var/log/mysqld.log | grep -i password
mysql -u root -p
mysql> alter user root@'localhost' identified by '1q2w#E$R';
五、创建账号
8.0
create user root@'%' identified with mysql_native_password by '1q2w#E$R'; root和%这个是一对一匹配的
grant all on *.* to root@'%'; all 是代表所有权限 *.* 是所有库的所有表
< 5.7
grant all on *.* to root@'%' identified by '1q2w#E$R';
六、修改配置文件的方法
1、在mysql客户端里修改参数值
2、通过修过/etc/my.cnf修改参数值
七、卸载mysql5.7的方法
yum remove mysql-community*
八、安装8.0
vim /etc/yum.repo.d/mysql-community.repo
将mysql5.7的enabled=0
将mysql8.0的enabled=1
yum install mysql-community-server
六、错误解决
1251 client does not support
原因: 是因为8.0启用了一个新的密码验证插件cache2,而老版本的mysql客户端不支持此协议
解决:
create user root@'%' identified with mysql_native_password by '1q2w#E$R';