设为首页 加入收藏

TOP

CentOS 7 MySql 解压版安装配置(一)
2019-09-17 18:53:55 】 浏览:61
Tags:CentOS MySql 解压 安装 配置

下载

  1. 访问www.mysql.com
  2. 点击DOWNLOADS-->Community-->MySQL Community Server
  3. 选择要下载的版本,目前可选择的有:5.55.65.78.0,这里以5.7为例,所以选择的是5.7
  4. 操作系统选择Red Hat Enterprise Linux / Oracle Linux,操作系统版本选择Red Hat Enterprise Linux 7 / Oracle Linux 7 (x86, 64-bit),下面列表过滤的找到Compressed TAR Archivetar压缩文件下载即可,这里选择的是mysql-5.7.25-el7-x86_64.tar.gz

将文件下载到CentOS服务器上,或者通过Windows下载后上传到CentOS服务器上。

(这里将文件放到/opt/soft/mysql-5.7.25-el7-x86_64.tar.gz

安装配置

1、添加组和用户

[root@localhost ~]: groupadd mysql
[root@localhost ~]: useradd -r -g mysql mysql

2、解压到指定位置

这里准备将mysql放到/opt/program/mysql目录中。

  1. 创建/opt/program/目录。
  2. 进入到/opt/program/目录。
  3. 解压/opt/soft/mysql-5.7.25-el7-x86_64.tar.gz文件,不指定目录的话,会解压到用户所在的目录(也就是/opt/program/)。
  4. 重新命名文件夹名为mysql
  5. 创建数据库目录data
[root@localhost ~]: mkdir /opt/program
[root@localhost ~]: cd /opt/program
[root@localhost program]: tar -zxvf /opt/soft/mysql-5.7.25-el7-x86_64.tar.gz
mysql-5.7.25-el7-x86_64/bin/myisam_ftdump
mysql-5.7.25-el7-x86_64/bin/myisamchk
mysql-5.7.25-el7-x86_64/bin/myisamlog
mysql-5.7.25-el7-x86_64/bin/myisampack
mysql-5.7.25-el7-x86_64/bin/mysql
…………
[root@localhost program]: mv mysql-5.7.25-el7-x86_64 mysql
[root@localhost program]: mkdir mysql/data

3、给用户和组赋权

[root@localhost ~]: chown -R mysql:mysql /opt/program/mysql

4、初始化mysql数据库

初始化需要指定mysql程序的目录以及数据库的目录

[root@localhost ~]: /opt/program/mysql/bin/mysqld  --initialize  --user=mysql  --basedir=/opt/program/mysql  --datadir=/opt/program/mysql/data
2019-03-16T14:28:52.317678Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2019-03-16T14:28:54.382317Z 0 [Warning] InnoDB: New log files created, LSN=45790
2019-03-16T14:28:54.699000Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2019-03-16T14:28:54.772198Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: d3d169f0-47f7-11e9-9ce7-000c291627c9.
2019-03-16T14:28:54.773910Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2019-03-16T14:28:54.775717Z 1 [Note] A temporary password is generated for root@localhost: hxwVZi*0-e3<

警告可以先不管,最后的位置是随机生成的root密码hxwVZi*0-e3<

5、配置my.cnf文件

mysql启动时,默认会查找/etc/my.cnf文件作为配置文件。

[root@localhost ~]: vi /etc/my.cnf

配置示例如下:

[mysql]
default-character-set=utf8

[mysqld]
lower_case_table_names=1
basedir=/opt/program/mysql
datadir=/opt/program/mysql/data
port=3306
character-set-server=utf8
max_connections=2000
innodb_buffer_pool_size=128M
log-error=/opt/program/mysql/data/error.log
pid-file=/opt/program/mysql/data/mysql.pid
socket=/opt/program/mysql/mysql.sock

6、为mysql配置环境变量

可以通过/etc/profile文件配置。

[root@localhost ~]: vi /etc/profile

打开该文件,在最末尾的位置加上

PATH=$PATH:/opt/program/mysql/bin

保存退出,再执行

[root@localhost ~]: source /etc/profile

通过# echo $PATH可以查看环境变量信息

7、制作自启动服务

第一种,将mysql.server复制到/etc/ini.d/目录下配置自启动服务

[root@localhost ~]: cp /opt/program/mysql/support-files/mysql.server /etc/ini.d/mysql
[root@localhost ~]: chmod +x /etc/ini.d/mysql
[root@localhost ~]: chkconfig --add mysql

通过# ch

首页 上一页 1 2 下一页 尾页 1/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇Oracle数据库操作---基础使用(二) 下一篇hbase rowkey 的设计

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目