centos7安装musql57
1、下载 MySQL Yum Repository
wget http:``//dev``.mysql.com``/get/mysql57-community-release-el7-10``.noarch.rpm
2、添加 MySQL Yum Repository
yum -y ``install` `mysql57-community-release-el7-10.noarch.rpm
3、安装mysql社区版
yum -y ``install` `mysql-community-server
WARING
描述:
MySQL GPG 密钥已过期。有关案例的其他详细信息也可以在 MySQL 网站上找到: https 😕/bugs.mysql.com/bug.php?id=106188
解决方法:
Note
If you are using RPM 4.1 and it complains about (GPG) NOT OK (MISSING KEYS: GPG#3a79bd29), even though you have imported the MySQL public build key into your own GPG keyring, you need to import the key into the RPM keyring first. RPM 4.1 no longer uses your personal GPG keyring (or GPG itself). Rather, RPM maintains a separate keyring because it is a system-wide application and a user’s GPG public keyring is a user-specific file. To import the MySQL public key into the RPM keyring, first obtain the key, then use rpm --import to import the key. For example:
可以在运行安装程序之前导入密钥:
rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
之后再执行yum install mysql-devel 就over了
4、查看mysql服务状态
service mysqld status
5、启动mysql服务
service mysqld start
其它:
systemctl status mysqld >>> 查看服务状态
systemctl start mysqld >>> 启动服务
mysql -u root -p >>> 登录mysql
service mysql restart >>> 重启mysql
7、查看root初始密码
grep` `"password"` `/var/log/mysqld``.log
8、登录mysql
mysql -uroot -p
9、修改root密码
ALTER USER 'root'@'localhost' IDENTIFIED BY 'new password';
密码注意有大小写复杂度要求,例如: Li!1234
10、添加新用户
mysql > grant all privileges on . to ``'userName'``@``'%'` `identified by ``'Li@1234'` `with grant option;
退出mysql 命令 – exit
======= 其它配置 ================================================================================================
1、火墙打开3306端口
netstat` `-anp | ``grep` `:3306 >>> 查看端口是否启用<br>firewall-cmd --zone=public --add-port=3306``/tcp` `--permanent
2、就是因为安装了Yum Repository,以后每次yum操作都会自动更新,需要把这个卸载掉
yum -y remove mysql57-community-release-el7-10.noarch.rpm -- 5.7版本
<br>yum -y remove mysql80-community-release-el7-1.noarch <em ``id``=``"__mceDel"``>-- 8.0版本<``/em``>
3、开机启动:
systemctl ``enable` `mysqld``systemctl daemon-reload
4、配置默认编码为utf8
改/etc/my.cnf配置文件,在[mysqld]下添加编码配置,如下所示:
[mysqld]``character_set_server=utf8``init_connect=``'SET NAMES utf8'
5、mysql开启远程访问
update更新方法
mysql > update mysql.user set host = '%' where user = 'root';
by:dada