xSky 实验室关注高性能计算,分布式系统/存储,大数据/机器学习/WebRTC
目录
  • 首页
  • 技术相关
  • 原创作品
  • 人工智能/机器学习
  • 系统与架构
  • 数据库/数据分析
  • 分布式系统/存储
  • 服务端开发
  • WEBRTC研究
  • 开发调试
  • 网络与安全
  • 常用工具
  • 杂七杂八

CentOS 二进制安装MySQL8.0.12

2018-10-17 08:46:01

运行环境:centos+mysql8.0.12
1.下载官方打包好的二进制安装包:
#wget https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-8.0.12-linux-glibc2.12-x86_64.tar.xz
可以看到这个版本采用了tar.xz的打包压缩方式,文件只有350M左右,下载还是满方便的。
# du -sh mysql-8.0.12-linux-glibc2.12-x86_64.tar.xz
339M mysql-8.0.12-linux-glibc2.12-x86_64.tar.xz

2.解压文件:
#tar -xJvf mysql-8.0.12-linux-glibc2.12-x86_64.tar.xz -C /usr/local/
# mv /usr/local/mysql-8.0.12-linux-glibc2.12-x86_64/ /usr/local/mysql

3.配置参数文件:
# cat /etc/my.cnf
[mysqld]
server-id = 1
port = 3306
mysqlx_port = 33060
mysqlx_socket = /tmp/mysqlx.sock
datadir = /data/mysql
socket = /tmp/mysql.sock
pid-file = /tmp/mysqld.pid
log-error = error.log
slow-query-log = 1
slow-query-log-file = slow.log
long_query_time = 0.2
log-bin = bin.log
relay-log = relay.log
binlog_format =ROW
relay_log_recovery = 1
character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
init_connect ='SET NAMES utf8mb4'
innodb_buffer_pool_size = 1G
join_buffer_size = 128M
sort_buffer_size = 2M
read_rnd_buffer_size = 2M
log_timestamps = SYSTEM
lower_case_table_names = 1
default-authentication-plugin =mysql_native_password

4.创建目录授权等:
# groupadd mysql
# useradd mysql
# mkdir -p /data/mysql
# chown -R mysql:mysql /data/mysql/
# chmod -R 775 /data/mysql/


5.初始化数据库:
#/usr/local/mysql/bin/mysqld --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql --initialize-insecure
官方推荐使用--initialize,会在错误日志中生成难以输入的临时密码,我这里使用的免密码的方式。

# cat /data/mysql/error.log | grep -i password
2018-07-29T02:06:41.253856+08:00 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: wquR3-Kxlg1d


6.设置启动文件和环境变量:
#cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
--启动数据库:
# /etc/init.d/mysql start
Starting MySQL.Logging to '/data/mysql/error.log'.
SUCCESS!

这里遇到启动报错:

Starting MySQL. ERROR! The server quit without updating PID file (/tmp/mysqld.pid).

cat /data/mysql/error.log

有如下两行:
2018-10-17T20:34:21.199512+08:00 0 [ERROR] [MY-012681] [InnoDB] InnoDB: mmap(137428992 bytes) failed; errno 12

2018-10-17T20:34:21.199570+08:00 1 [ERROR] [MY-012956] [InnoDB] InnoDB: Cannot allocate memory for the buffer pool

内存分配出错,把上面配置文件内的内存参数改小点。


# vim /etc/profile.d/mysql.sh
# cat /etc/profile.d/mysql.sh
export PATH=$PATH:/usr/local/mysql/bin
# source /etc/profile.d/mysql.sh
# mysqld --version
mysqld Ver 8.0.12 for linux-glibc2.12 on x86_64 (MySQL Community Server - GPL)
[root@node4 mysql]# /usr/local/mysql/bin/mysql -p -S /tmp/mysql.sock
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 8.0.12 MySQL Community Server - GPL
Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> select version();
+-----------+
| version() |
+-----------+
| 8.0.12 |
+-----------+
1 row in set (0.00 sec)
7.设置可以远程登录的账号:
mysql> show variables like '%valid%pass%';
Empty set (0.00 sec)
mysql> create user root@'%' identified by 'oracle';
ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
mysql> show variables like '%valid%pass%';
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql> alter user root@'localhost' identified by 'oracle';
Query OK, 0 rows affected (0.07 sec)
mysql> show variables like '%valid%pass%';
Empty set (0.01 sec)
--创建可以远程登录的用户:
mysql> create user root@'%' identified by 'oracle';
Query OK, 0 rows affected (0.06 sec)
mysql> grant all privileges on *.* to root@'%' with grant option;
Query OK, 0 rows affected (0.07 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
总结:
官方虽然提供RPM安装方式但是不少默认参数还是不太方便平常的使用,对生产而言则需要修改更多的地方,但是很适合初级用户快速安装使用;
而对二进制安装包 只需要下载按照自定义的设置安装即可 方便快捷 可自主配置,适合生产布署。

By:xSky | 技术相关 |

  • 分类目录

    • 技术相关 (18)
    • 原创作品 (11)
    • 人工智能/机器学习 (2)
    • 系统与架构 (9)
    • 数据库/数据分析 (8)
    • 分布式系统/存储 (4)
    • 服务端开发 (7)
    • WEBRTC研究 (6)
    • 开发调试 (8)
    • 网络与安全 (3)
    • 常用工具 (8)
    • 杂七杂八 (5)
  • 最新文章

    • 翻译:使用 Semgrep 进行热点代码评审
    • 共享内存并发路线图
    • 优化 QUIC 的 ACK 机制
    • QUIC 上的 RTP
    • [译] [论文] BBR:基于拥塞(而非丢包)的拥塞控制(ACM, 2017)
    • BBR拥塞控制算法
    • congestion_controller、 remote bitrate estimator、pacing模块浅析
    • 实战|QUIC协议在蚂蚁集团落地
    • 阿里XQUIC:标准QUIC实现自研之路
    • 弱网不弱-TQUIC助力业务提速30%
    • 程序员眼中最有价值的10条开发经验
    • 一文看懂WebTransport
    • QUIC协议和HTTP3.0研究
    • QUIC 协议在蚂蚁集团落地之综述
    • 机器视觉开源代码集合
    • 国外机器人实验室的开源项目
    • shell里配置代理
    • Envoy为什么能战胜Ngnix——线程模型分析篇 
    • VScode: 常用快捷键
    • ARM版群晖安装软件
    • 关于RTP中的时间戳问题
    • Address Sanitizer 用法
    • 使用google heap profiler进行内存占用分析
    • Linux中的常用内存问题检测工具
    • 超文本传输​​协议版本3 (HTTP/3)
    • Linux TCP队列相关参数的总结
    • xRedis 1.4 版本发布!
    • 编程类中文开源电子书合集
    • 史上最全的WebRTC服务器技术选型分析
    • 百亿流量微服务网关的设计与实现
  • 链接

    • xSky的Blog
    • 我的Github
    • 实时监控图表
    • 预印本
    • xRedis 在线文档
    • xSkyProxy
    • xChart 数据在线测试
    • 我的电子书
    • xChart 数据可视化系统
    • 树莓派技术圈
    • WebRTC开发者社区
  • 开源项目

    • xReis C++的redis客户端库
    • xBlog-C++ 博客程序
    • xSkyProxy-新的MySQL代理网关
    • 数据可视化平台- xChart
    • xhttpcache 高速数据缓存服务
    • xMonitor-图形监测工具
    • test

Powered By xBlog

Copyright 0xsky.com All Rights Reserved.