Mysql安装配置

Mysql安装配置

Centos安装Mysql

1.查看是否安装mysql
rpm -qa|grep -i mysql

2.卸载mysql
rpm –ev 包名

3.查看mysql相关
find / -name mysql

4.删除
rm –rf 目录名

5.查询是否安装mariadb
rpm -qa | grep mariadb

6.卸载mysql
rpm -e --nodeps 包名

7.官方下载安装包
mysql-community-common-8.0.25-1.el7.x86_64.rpm
mysql-community-libs-8.0.25-1.el7.x86_64.rpm
mysql-community-client-8.0.25-1.el7.x86_64.rpm
mysql-community-server-8.0.25-1.el7.x86_64.rpm

8.按照顺序安装
rpm -ivh mysql-community-common-8.0.25-1.el7.x86_64.rpm --force --nodeps
rpm -ivh mysql-community-libs-8.0.25-1.el7.x86_64.rpm --force --nodeps
rpm -ivh mysql-community-client-8.0.25-1.el7.x86_64.rpm --force --nodeps
rpm -ivh mysql-community-server-8.0.25-1.el7.x86_64.rpm --force --nodeps

9.启动mysql
service mysqld start

10.查看mysql状态
service mysqld status

11.查看mysql的临时密码
grep "A temporary password" /var/log/mysqld.log

12.登录mysql
mysql -uroot -p

13.重新设置密码
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'Root_demo01';

14.设置密码策略
set global validate_password.length=4;
set global validate_password.policy=0;

15.刷新
flush privileges;

15.查看密码策略
SHOW VARIABLES LIKE 'validate_password%';

17.重新设置密码
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';

18.切换数据库
use mysql;

19.所有的地址都可以使用root用户来登陆
update user set host = '%' where user ='root';

20.刷新
flush privileges;

21.退出数据库
exit;
上一篇:CentOS7安装MySQL:用RPM安装包方式(推荐)


下一篇:2021-06-07