本文主要是记录一下供以后安装方便
配置文件:/etc/my.cnf
mysql位置:/var/lib/mysql
检测系统是否有mysql
rpm -qa | grep mysql
有的话删掉
// 普通删除模式
rpm -e mysql
// 强力删除模式,如果使用上面命令删除时,提示有依赖的其它文件,则用该命令可以对其进行强力删除
rpm -e --nodeps mysql(或者把mysql改成rpm -qa | grep mysql搜到的东西)
下载rpm
wget https://repo.mysql.com//mysql80-community-release-el7-1.noarch.rpm
rpm -ivh mysql80-community-release-el7-1.noarch.rpm
若没有wget:yum -y install wget
安装mysql-server
yum install mysql-server
大小写不敏感
vim /etc/my.cnf
lower_case_table_names=1
初始化
mysqld --initialize
启动 mysqld
systemctl start mysqld
mysql -uroot -p登录,如果登录不上,vim/etc/my.cnf, 尾部 skip-grant-tables
重启 mysqld
systemctl restart mysqld
mysql -uroot
更改密码为空字符串
update user set authentication_string='' where user='root';
退出,然后把skip-grant-tables注释重启mysql
用空字符串登录
mysql -uroot -p
修改密码: Access denied for user ‘root’@’localhost’和cahche sha2 password问题
use mysql;
#修改任何ip可连
update user set host = '%' where user = 'root'
#修改密码
alter user user() identified by 'root'; (我现在得用这个,下面这个没用)
或者
ALTER user 'root'@'%' IDENTIFIED BY 'root';
提示格式不对:Your password does not satisfy the current policy requirements
而且你就想设置 密码为 123456,怎么办?
a、先设置为符合规范的密码: Abc123...
ALTER USER 'root'@'%' IDENTIFIED BY 'Abc123...';
b、然后查看当前默认规则:SHOW VARIABLES LIKE 'validate_password%';
c、修改校验密码策略等级
set global validate_password.policy=LOW;
d、设置密码长度至少为 6
set global validate_password.length=6;
e、最后设置 123456
ALTER USER 'root'@'%' IDENTIFIED BY '123456';
flush privileges;
关闭防火墙
systemctl stop firewalld
systemctl disble firewalld
配置虚拟机网络
vim /etc/sysconfig/network-scripts/ifcfg-ens33
TYPE=Ethernet
BOOTPROTO=static
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=ens33
UUID=54c29183-b09e-4f9b-a3d5-f2c7f04f1b75
DEVICE=ens33
ONBOOT=yes
IPADDR=192.168.131.100
NETMASK=255.255.255.0
GATEWAY=192.168.131.2
DNS1=8.8.8.8
配置好了还是没有ip或者有时候因为关机没有ip
systemctl stop NetworkManager
systemctl disable NetworkManager
systemctl start network