前提准备:
MySQL下载 https://dev.mysql.com/downloads/mysql/
当前安装版本5.7
1.检查是否安装mysql:rpm -aq | grep mysql
如果有输出则先停止服务: service mysqld start
批量删除包 rpm -e XXX --nodeps
2.检查mariadb:rpm -qa|grep mariadb
如果有输出则删除相关包 rpm -e XXX --nodeps
3.删除目录:find / -name mysql
如果有根据目录进行删除: rm -rf XXX
4.删除 my.conf: rm -rf my.conf
5.创建mysql目录: mkdir /usr/local/mysql
6.复制安装包到该目录下:cp ~/download/mysql-5.7.12-1.el6.x86_64.rpm-bundle.tar /usr/local/mysql/
7.解压缩安装包:
cd /usr/local/mysql/
tar -xf mysql-5.7.12-1.el6.x86_64.rpm-bundle.tar
8.按顺序执行如下安装:
rpm -ivh mysql-community-common-5.7.12-1.el6.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.12-1.el6.x86_64.rpm
rpm -ivh mysql-community-client-5.7.12-1.el6.x86_64.rpm
rpm -ivh imysql-community-server-5.7.12-1.el6.x86_64.rpm
rpm -ivh mysql-community-devel-5.7.12-1.el6.x86_64.rpm
9.启动mysql: systemctl start mysqld.service
10.查看启动状态:systemctl status mysqld.service
11.启动之后密码就创建好了,通过:sudo grep 'temporary password' /var/log/mysqld.log 查看密码
12.登录mysql:mysql -uroot -p
13.修改密码:set password for 'root'@'localhost'='123456';
14.设置允许外网访问:
use mysql;
select user,host from user;
update user set host='%' where user='root';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'mypwd' WITH GRANT OPTION;
flush privileges;
标签:12,Redhat,5.7,el6,配置,64,mysql,rpm From: https://www.cnblogs.com/suoyiling/p/17994470