Mysql
安装Mysql8
先卸载MariaDB
rpm -qa | grep -i mariadb
rpm -e --nodeps mariadb-libs-5.5.64-1.el7.x86_64
rpm -e --nodeps mariadb-5.5.64-1.el7.x86_64
检查是否有mysql残留
rpm -qa | grep mysql
下载mysql库
wget https://repo.mysql.com//mysql80-community-release-el7-3.noarch.rpm
安装mysql库
yum -y install mysql80-community-release-el7-3.noarch.rpm
重新获取mysql的GPG
rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
安装mysql
yum -y install mysql-community-server
查看默认密码 (我一般不看 设置免密登录)
cat /var/log/mysqld.log | grep password
设置mysql免密码登录,以便进行修改密码操作
vim /etc/my.cnf
添加skip-grant-tables
wq!保存退出
开启mysql服务
systemctl start mysqld
检查mysql运行状态
systemctl status mysqld
mysql -u root -p
已免密,按任意键登录
密码限制调低
use mysql;
set global validate_password.policy=0;
set global validate_password.length=4;
flush privileges;
SHOW variables LIKE 'validate_password%';
修改密码 创建用户 赋权
ALTER USER 'root'@'localhost' IDENTIFIED BY '1234';
CREATE USER 'root'@'%' IDENTIFIED BY '1234';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%';
flush privileges;
exit;
取消免密码登录
vim /etc/my.cnf
删除skip-grant-tables
systemctl restart mysqld
mysql -u root -p
输入密码 能进去 就是安装成功了
创建数据库 导SQL文件
create database 库名;
mysql -u root -p 库名< sql文件