Centos7系列安装mysql(Server version: 5.7.35) 1、下载并安装MySQL官方的 Yum Repository wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm yum -y install mysql57-community-release-el7-10.noarch.rpm 2、yum安装MySQL,安装完成后就会覆盖掉之前的mariadb yum -y install mysql-community-server 3、启动mysql服务 systemctl start ?mysqld.service systemctl status mysqld.service 4、登录mysql #查看mysql密码 grep "password" /var/log/mysqld.log #如下命令进入数据库 mysql -uroot -p 5、修改mysql默认密码策略 #修改默认密码,密码必须符合复杂度要求,修改完成后才能继续使用 ALTER USER 'root'@'localhost' IDENTIFIED BY 'z?guwrBhH7p>'; #查看默认密码策略 SHOW VARIABLES LIKE 'validate_password%'; #修改密码策略 set global validate_password_policy=0; set global validate_password_length=1; #再次修改自己熟悉的密码 ALTER USER 'root'@'localhost' IDENTIFIED BY 'new password'; 6、切换数据库 use mysql #查看表 show tables #查看表的的表明 desc ?mysql; 查看表的数据 select host,user,password from user; #增加数据(远程用户数据访问)可视化工具的登录授权: grant all privileges on *.* to 'root'@'%' identified by '123' ?with grant option #刷新全新或者重启mysqld服务(systemctl restart mysqld.service) flush privileges;
|