参考其他在线安装mysql教程:
安装mysql wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm wget --no-check-certificate http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm yum localinstall mysql57-community-release-el7-8.noarch.rpm yum repolist all | grep mysql yum install -y yum-utils yum-config-manager --enable mysql57-community yum-config-manager –disable mysql56-community yum repolist all | grep mysql yum install mysql-server mysql 启动命令 systemctl start mysqld mysql 关闭 systemctl stop mysqld 查看mysql状态 status mysqld.service 修改密码 ALTER USER 'root'@'localhost' IDENTIFIED BY 'root';
1、创建工作目录
链接: mysql-rpm 包链接地址 密码: wnod
mkdir /usr/mysql 上传安装包mysql-5.7.25-1.el7.x86_64.rpm-bundle.tar 到工作目录 执行解压命令: tar -xvf mysql-5.7.25-1.el7.x86_64.rpm-bundle.tar
2、清除依赖:
yum remove mysql-libs 清除依赖
3、安装:(若报错,在后面加上 --nodeps)
- rpm -ivh mysql-community-common-5.7.25-1.el7.x86_64.rpm - rpm -ivh mysql-community-libs-5.7.25-1.el7.x86_64.rpm - rpm -ivh mysql-community-libs-compat-5.7.25-1.el7.x86_64.rpm - rpm -ivh mysql-community-client-5.7.25-1.el7.x86_64.rpm - rpm -ivh mysql-community-server-5.7.25-1.el7.x86_64.rpm
4、初始化启动:
/usr/sbin/mysqld --initialize-insecure --user=root
5、启动服务并设置后台运行模式
/usr/sbin/mysqld --user=root &
6、登录MYSQL
mysql -uroot
7、重置 MySQL 密码
alter user 'root'@'localhost' identified by 'root';
8、登录mysql
mysql -uroot -proot
9、增加远程登录权限
mysql> use mysql; # 切换成mysql数据库
mysql> select user,host from user; # 查询用户信息
10、设置远程登录权限
- 实现远程连接(授权法)
mysql> update user set host='%' where host='localhost';
11、刷新配置信息
mysql> flush privileges;
12、测试
create database test;