centos7下离线安装mysql

Posted 沙漏无语

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了centos7下离线安装mysql相关的知识,希望对你有一定的参考价值。

在线安装:

yum -y install mysql-server

离线安装:

1.删除原有的mariadb,不然mysql装不进去

1

2

3

mariadb-libs-5.5.52-1.el7.x86_64

rpm -qa|grep mariadb

rpm -e --nodeps mariadb-libs

1.在https://dev.mysql.com/downloads/mysql/选择为Red Hat Enterprise Linux 7 / Oracle Linux 7 ,把os的版本选择为all。

直接下载mysql-5.7.21-1.el7.x86_64.rpm-bundle.tar,所有的rpm包都在里面

1

2

3

4

5

6

rpm -ivh mysql-community-common-5.7.21-1.el7.x86_64.rpm

 rpm -ivh mysql-community-libs-5.7.21-1.el7.x86_64.rpm

rpm -ivh mysql-community-devel-5.7.21-1.el7.x86_64.rpm

rpm -ivh mysql-community-libs-compat-5.7.21-1.el7.x86_64.rpm

rpm -ivh mysql-community-client-5.7.21-1.el7.x86_64.rpm

 rpm -ivh mysql-community-server-5.7.21-1.el7.x86_64.rpm

至此,mysql5.7所有文件安装完毕,接下来就是开启服务测试了。

1.首先关闭mysql服务:

service mysqld stop

2.然后修改配置文件:

vim /etc/my.cnf

3.接下来加入一句代码即可空密码登录mysql:

1

2

3

# Disabling symbolic-links is recommended to prevent assorted security risks

skip-grant-tables   #添加这句话,这时候登入mysql就不需要密码

symbolic-links=0

4.开启mysql服务:

service mysqld start

5.空密码登录mysql:

mysql -u root -p    #输入命令回车进入,出现输入密码提示直接回车

6.设置mysql密码:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

mysql> set password for root@localhost = password('123456');

ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement

mysql> flush privileges; #更新权限

Query OK, 0 rows affected (0.00 sec)

mysql> set password for root@localhost = password('123456');

Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql>flush privileges; #更新权限

mysql>quit; #退出

service mysqld stop # 停止mysql服务, 恢复mysql配置

vim /etc/my.cnf   #修改配置文件

# Disabling symbolic-links is recommended to prevent assorted security risks

# skip-grant-tables # 注释掉这句话

symbolic-links=0

service mysqld start # 启动mysql服务

mysql -uroot -p # 输入新密码登录

7.设置mysql开机自启:

systemctl enable mysqld

 

查看是否有 libaio

rpm -qa|grep libaio

没有的话请下载:

http://mirror.centos.org/centos/7/os/x86_64/Packages/libao-1.1.0-8.el7.x86_64.rpm

以上是关于centos7下离线安装mysql的主要内容,如果未能解决你的问题,请参考以下文章

centos7下离线安装mysql8的详细安装图解

离线安装系列2:在CentOS7下离线安装jdk11

离线安装系列4:在CentOS7下离线安装nginx

centos7.4下离线安装CDH5.7

CentOs7 内网环境下离线安装Oracle

CentOs7 内网环境下离线安装Oracle