安装mysql 本文共有3191个字,关键词: 安装mysql8 wget -i -c https://repo.mysql.com//mysql80-community-release-el7-1.noarch.rpm yum -y install mysql80-community-release-el7-1.noarch.rpm 或者下面一句 yum localinstall https://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm yum install mysql-community-server #--------------------------------------- gpg --export -a 3a79bd29 > 3a79bd29.asc rpm --import 3a79bd29.asc rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022 #--------------------------------------- yum install mysql-community-server /etc/my.cnf 文件中添加如下配置: lower_case_table_names=1 #启动mysql8 systemctl start mysqld.service #查看mysql8运行状态 systemctl status mysqld.service #获取密码 grep "password" /var/log/mysqld.log mysql -uroot -p #修改一个复杂的密码: ALTER USER 'root'@'localhost' IDENTIFIED BY '你的复杂密码'; #查看密码策略: SHOW VARIABLES LIKE 'validate_password%'; #mysql8的密码策略是 validate_password.policy #而mysql5的时候密码策略是 validate_password_policy 修改策略为低级: set global validate_password.policy=LOW; set global validate_password.length = 1; 即: ### ALTER USER 'root'@'localhost' IDENTIFIED BY '!!QQqq123'; set global validate_password.policy=LOW; set global validate_password.length = 1; ALTER USER 'root'@'localhost' IDENTIFIED BY '123456'; ### #添加一个用户用来远程访问 CREATE USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '123456'; GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'; 开放防火墙3306端口 firewall-cmd --permanent --zone=public --add-port=3306/tcp 如果防火墙关闭状态,可以先打开 1> 查看防火墙状态: systemctl status firewalld 2>开启防火墙:systemctl start firewalld 开启防火墙以后再执行开放端口命令即可。 刷新防火墙 firewall-cmd --reload 如果你用navicat客户端登录可能会报错,因为密码认证方式不支持,默认是 caching_sha2_password,可以修改 /etc/my.cnf文件改变密码认证方式为 mysql_native_password 在my.cnf文件的[mysqld]下面加上如下配置: default_authentication_plugin=mysql_native_password 更改存储路径 mkdir /data/mysql chown -R mysql:mysql /data/mysql systemctl stop mysqld cp -Rp /var/lib/mysql/* /data/mysql cp /etc/my.cnf /etc/my.cnf.ori 修改my.cnf [mysqld] datadir=/data/mysql socket=/data/mysql/mysql.sock [client] port=3306 socket=/data/mysql/mysql.sock #ln -s /data/mysql/mysql.sock /var/lib/mysql/mysql.sock setenforce 0 sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config;cat /etc/selinux/config systemctl start mysqld #进入mysql运行 以确认是否更改 select @@datadir; 「一键投喂 软糖/蛋糕/布丁/牛奶/冰阔乐!」 赞赏 × 梦白沙 (๑>ڡ<)☆谢谢老板~ 1元 2元 5元 10元 50元 任意金额 2元 使用微信扫描二维码完成支付 版权声明:本文为作者原创,如需转载须联系作者本人同意,未经作者本人同意不得擅自转载。 CentOS 2022-07-04 评论 714 次浏览