ICode9

精准搜索请尝试: 精确搜索
首页 > 数据库> 文章详细

Linux Mysql-8.0.23 安装配置

2021-01-26 18:32:37  阅读:88  来源: 互联网

标签:8.0 23 Mysql Linux mysqld mysql 3306 data


Mysql 运维笔记

MySQL 8 正式版 8.0.11 已发布,官方表示 MySQL 8 要比 MySQL 5.7 快 2 倍,还带来了大量的改进和更快的性能!

Mysql 5.7 之前是用utf8 ,8.0之后使用 默认编码使用utf8mb4, utf8mb4更全,包含了utf8

 

服务器初始化

#调整swap

echo 0 > /proc/sys/vm/swappiness 

vim /etc/sysctl.conf

vm.swappiness = 0

#安装包

yum install -y cmake gcc gcc-c++ ncurses ncurses-devel bison zlib zlib-devel libxml openssl openssl-devel automake autoconf make libtool bison-devel libaio-devel

#创建用户

useradd -s /sbin/nologin mysql
 

 

下载完了之后解压文件

#下载
cd /opt

wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.23-linux-glibc2.12-x86_64.tar.xz

# 解压分两步
xz -d mysql-8.0.23-linux-glibc2.12-x86_64.tar.xz 
tar xf mysql-8.0.23-linux-glibc2.12-x86_64.tar 

mv mysql-8.0.23-linux-glibc2.12-x86_64 /usr/local/mysql

 

系统配置

#Mysql文件目录

cd /usr/local/
chown -R mysql. mysql

#数据目录

mkdir -p /data/mysql/3306/data /data/mysql/3306/binlog 

chown -R mysql. /data/mysql

#修改环境变量

vim /etc/profile.d/mysql.sh
export PATH=/usr/local/mysql/bin:$PATH
source /etc/profile.d/mysql.sh

使用system 关联启动

vim /etc/systemd/system/mysqld.service
[Unit]
Description=MySQL Server
Documentation=man:mysqld(8)
Documentation=http://dev.mysql.com/doc/refman/en/using-systemd.html
After=network.target
After=syslog.target
[Install]
WantedBy=multi-user.target
[Service]
User=mysql
Group=mysql
ExecStart=/usr/local/mysql/bin/mysqld --defaults-file=/data/mysql/3306/my.cnf
LimitNOFILE = 5000

 systemctl daemon-reload 
 systemctl enable mysqld

Mysql 配置文件

cat my.cnf 
[client]
port            = 3306
socket          = /data/mysql/3306/mysql.sock

[mysqld]
basedir   = /usr/local/mysql
datadir   = /data/mysql/3306/data
port      = 3306
socket    = /data/mysql/3306/mysql.sock
log-error = /data/mysql/3306/mysql_error.log
pid-file  = /data/mysql/3306/mysql.pid
log-bin = /data/mysql/3306/binlog/binlog

skip-host-cache
skip-name-resolve
# 独立表空间
innodb_file_per_table = 1
# 内存池
innodb_buffer_pool_size = 2G
innodb_flush_log_at_trx_commit = 1

innodb_flush_method=O_DIRECT

[mysqld_safe]
 

初始化数据库

mysqld --defaults-file=/data/mysql/3306/my.cnf --initialize --user=mysql

#日志中会有密码

grep "password"  /data/mysql/3306/mysql_error.log 

C9O3+1&c671S

#启动数据库

systemctl start mysqld

Mysql 基础操作

#第一次登陆需要修改密码
mysql -uroot -p -S mysql.sock
mysql> show databases;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

mysql> alter user root@'localhost' identified by '123456';
Query OK, 0 rows affected (0.01 sec)

# 创建用户 5.6/5.7 中直接grant 带账号以及授权已无法使用
mysql> create user root@'10.10.10.%' identified by '123456';
mysql> grant all on *.* to  root@'10.10.10.%';

#连接数据库
mysql -uroot -p -S mysql.sock
mysql -uroot -p -hxxx -Pxxx

 

 

标签:8.0,23,Mysql,Linux,mysqld,mysql,3306,data
来源: https://blog.csdn.net/ganices/article/details/113184714

专注分享技术,共同学习,共同进步。侵权联系[admin#icode9.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有