当前位置:Gxlcms > 数据库问题 > Linux下安装MySQL

Linux下安装MySQL

时间:2021-07-01 10:21:17 帮助过:24人阅读

]# tar -xvf mysql-5.7.24-1.el6.x86_64.rpm-bundle.tar [root@server0 sh]# ls *.rpm mysql-community-client-5.7.24-1.el6.x86_64.rpm mysql-community-common-5.7.24-1.el6.x86_64.rpm mysql-community-devel-5.7.24-1.el6.x86_64.rpm mysql-community-embedded-5.7.24-1.el6.x86_64.rpm mysql-community-embedded-devel-5.7.24-1.el6.x86_64.rpm mysql-community-libs-5.7.24-1.el6.x86_64.rpm mysql-community-libs-compat-5.7.24-1.el6.x86_64.rpm mysql-community-server-5.7.24-1.el6.x86_64.rpm mysql-community-test-5.7.24-1.el6.x86_64.rpm

其中:

mysql-community-server-5.7.24-1.el6.x86_64.rpm 主程序包,提供服务的主包

mysql-community-client-5.7.24-1.el6.x86_64.rpm 管理工具数据库

剩下的都是辅助功能软件包,开始安装MySQL5.7:

[root@server0 sh]# rpm -Uvh mysql-community-*.rpm  #升级安装mysql,发现依赖包
warning: mysql-community-client-5.7.24-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
error: Failed dependencies:
     libnuma.so.1()(64bit) is needed by mysql-community-embedded-5.7.24-1.el6.x86_64
     libnuma.so.1(libnuma_1.1)(64bit) is needed by mysql-community-embedded-5.7.24-1.el6.x86_64
     libnuma.so.1(libnuma_1.2)(64bit) is needed by mysql-community-embedded-5.7.24-1.el6.x86_64
     libnuma.so.1()(64bit) is needed by mysql-community-server-5.7.24-1.el6.x86_64
     libnuma.so.1(libnuma_1.1)(64bit) is needed by mysql-community-server-5.7.24-1.el6.x86_64
     libnuma.so.1(libnuma_1.2)(64bit) is needed by mysql-community-server-5.7.24-1.el6.x86_64
     libnuma.so.1()(64bit) is needed by mysql-community-test-5.7.24-1.el6.x86_64
     libnuma.so.1(libnuma_1.1)(64bit) is needed by mysql-community-test-5.7.24-1.el6.x86_64
     libnuma.so.1(libnuma_1.2)(64bit) is needed by mysql-community-test-5.7.24-1.el6.x86_64
     perl(JSON) is needed by mysql-community-test-5.7.24-1.el6.x86_64
    perl(Time::HiRes) is needed by mysql-community-test-5.7.24-1.el6.x86_64

[root@server0 sh]# yum -y install libnuma.so.1*  #安装依赖包
[root@server0 sh]# yum -y install perl-JSON    #安装依赖包
[root@server0 sh]# yum -y install perl-Time-HiRes    #安装依赖包
[root@server0 sh]# rpm -Uvh mysql-community-*.rpm  #再次执行,成功安装
[root@server0 sh]# rpm -qa | grep -i mysql    #查询MySQL是否安装成功
mysql-community-common-5.7.24-1.el6.x86_64
mysql-community-devel-5.7.24-1.el6.x86_64
mysql-community-libs-compat-5.7.24-1.el6.x86_64
mysql-community-libs-5.7.24-1.el6.x86_64
mysql-community-server-5.7.24-1.el6.x86_64
mysql-community-embedded-5.7.24-1.el6.x86_64
mysql-community-test-5.7.24-1.el6.x86_64
mysql-community-client-5.7.24-1.el6.x86_64
mysql-community-embedded-devel-5.7.24-1.el6.x86_64

首次安装完成后mysql会自动创建/var/lib/mysql数据库目录,数据库目录/var/lib/mysql下是没有任何文件的,首次启动数据库的时候会数据初始化,初始化成功后在数据库目录/var/lib/mysql下自动生成文件,每次启动或重启数据库时会加载数据库目录下的文件,如果数据库目录下文件丢失那么会导致服务起不来!

[root@server0 mysql]# service mysqld start  #启动mysql
初始化 MySQL 数据库:                                      [确定]
正在启动 mysqld:                                          [确定]
[root@server0 mysql]# service mysqld status  #查询服务状态
mysqld (pid  7745) 正在运行...
[root@server0 mysql]# pwd;ls;
/var/lib/mysql
auto.cnf         client-key.pem  ib_logfile1  mysql.sock.lock     server-cert.pem
ca-key.pem       ib_buffer_pool  ibtmp1       performance_schema  server-key.pem
ca.pem           ibdata1         mysql        private_key.pem     sys
client-cert.pem  ib_logfile0     mysql.sock   public_key.pem
[root@server0 mysql]# chkconfig mysqld on  #设置mysql为开启自启动
[root@server0 mysql]# chkconfig mysqld --list
mysqld             0:关闭    1:关闭    2:启用    3:启用    4:启用    5:启用    6:关闭


mysql服务相关参数

主配置文件:/etc/my.cnf

数据库目录:/var/lib/mysql(自动创建)

默认端口号:3306

进程名:mysqld

传输协议:TCP

进程所有者:mysql

进程所属组:mysql


使用RPM安装方式会自动创建用户mysql,组mysql,数据库目录的属主组都是mysql,因为要对数据库目录进行读写;

[root@server0 ~]# ls -ld /var/lib/mysql
drwxr-x--x. 5 mysql mysql 4096 12月  4 23:21 /var/lib/mysql


总结:

1、解压

[root@server0 sh]# tar -xvf mysql-5.7.24-1.el6.x86_64.rpm-bundle.tar

2、装包,并且安装依赖包

[root@server0 sh]# rpm -Uvh mysql-community-*.rpm 

[root@server0 sh]# yum -y install libnuma.so.1* 

[root@server0 sh]# yum -y install perl-JSON

[root@server0 sh]# yum -y install perl-Time-HiRes

[root@server0 sh]# rpm -Uvh mysql-community-*.rpm 

3、启服务

[root@server0 mysql]# service mysqld start

4、开机自启

[root@server0 mysql]# chkconfig mysqld on











Linux下安装MySQL

标签:相关   sql   查询   acl   传输协议   col   html   mys   之间   

人气教程排行