1.命令安装
yum install mysql-server
2.启动mysql
service mysqld start
3.查看mysql状态
service mysqld status
4.加入开机启动
systemctl enable mysqld.service
5.修改密码
默认也是没有密码的直接回车输入新密码
mysqladmin -uroot -p password
Enter password: # 直接回车
New password:
Confirm new password:
Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety.
6.修改远程登录
# 使用密码登录
mysql -u root -p
# 使用mysql库
use mysql
# 查看认证模式,默认都是localhost
select user,authentication_string,host from user;
# 修改root用户为可远程登录
update user set host='%' where user='root';
# 刷新
flush privileges;
7.常见问题
远程登录密码验证报错:caching_sha2_password
# 使用密码登录
mysql -u root -p
# 使用mysql库
use mysql
# 将MySQL8的密码认证插件由caching_sha2_password更换成mysql_native_password:
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'passowrd';
文章评论