mysql8安装教程最新,mysql8.0.24安装教程

首页 > 经验 > 作者:YD1662022-11-04 05:07:44

系统环境下载 Mysql8 二进制包

wget https://dev.MYSQL.com/get/Downloads/MySQL-8.0/mysql-8.0.29-linux-glibc2.17-x86_64-minimal.tar.xz
#或者
wget https://dev.MySQL.com/get/Downloads/MySQL-8.0/mysql-8.0.29-linux-glibc2.12-x86_64-minimal.tar.xz

或者进入Mysql官网下载,点击以下链接直达下载地址:

https://dev.mysql.com/downloads/mysql/,根据对应信息,下载版本进行安装。

mysql8安装教程最新,mysql8.0.24安装教程(1)

环境配置

# enforcing 开启selinux
# permissive 宽松模式,记录但不操作
# disabled 关闭selinux
sed -i 's/SELINUX\=enforcing/SELINUX\=permissive/g' /etc/selinux/config

# 关闭防火墙
systemctl stop firewalld.service
# 关闭开机自动启动
systemctl disabled firewalld.service

查看 numa

[root@mysqldb_master mysql]# numactl --hardware
available: 1 nodes (0)
node 0 cpus: 0 1
node 0 size: 3736 MB
node 0 free: 2267 MB
node distances:
node 0
0: 10

available: 1 nodes (0) #如果是 2 或多个 nodes 就说明 numa 没关掉

或者

[root@mysqldb_master local]# dmesg | grep -i numa
[ 0.000000] No NUMA configuration found

如果输出结果为:
No NUMA configuration found
说明 numa 为 disable,如果不是上面的内容说明 numa 为 enable

关闭 numa

vim /etc/default/grub

mysql8安装教程最新,mysql8.0.24安装教程(2)

或者在 mysql 的 my.cnf 中,配置 innodb_numa_interleave 参数,将其设置为 ON

mysql> show variables like '%NUMA%';
ERROR 4031 (HY000): The client was disconnected by the server because of inactivity. See wait_timeout and interactive_timeout for configuring this behavior.
No connection. Trying to reconnect...
Connection id: 22
Current database: *** NONE ***
------------------------ -------
| Variable_name | Value |
------------------------ -------
| innodb_numa_interleave | OFF |
------------------------ -------
1 row in set (0.00 sec)

还有其他方式,如想知道请自行查询资料

echo "
* soft nproc 65535
* hard nproc 65535
* soft noFile 65536
* hard nofile 65536" >>/etc/security/limits.conf

安装数据库

如无特殊说明,都是使用 root 用户操作

groupadd -g 999 mysql
useradd -g mysql -s /sbin/nologin -d /usr/local/mysql -MN mysql

这里 bash 是 nologin,也就是没有 shell,用户不能登录 bash 中,提高安全性

cd /soft
tar -xvf mysql-8.0.27-linux-glibc2.17-x86_64.tar.xz

cd /usr/local
ls -s /soft/mysql-8.0.27-linux-glibc2.12-x86_64 mysql

cd /usr/local
unllink mysql

mkdir -p /data/mysql/{data,logs,tmp}
chow -R mysql:mysql /usr/local/mysql
chow -R mysql:mysql /data/mysql

/usr/local/mysql/bin/mysqld --defaults-file=/data/mysql/my.cnf --initialize

无密码:

/usr/local/mysql/bin/mysqld --defaults-file=/data/mysql/my.cnf --initialize-insecure

如果有问题,会马上返回,没问题,等一会就会返回。

日志如下:

[root@mysqldb_master logs]# cat error.log
2022-07-22T10:30:28.758075 08:00 0 [Warning] [MY-000081] [Server] option 'table_definition_cache': unsigned value 200 adjusted to 400.
2022-07-22T10:30:28.759983 08:00 0 [Warning] [MY-011068] [Server] The syntax 'log_slow_slave_statements' is deprecated and will be removed in a future release. Please use log_slow_replica_statements instead.
2022-07-22T10:30:28.760210 08:00 0 [Note] [MY-010096] [Server] Ignoring --secure-file-priv value as server is running with --initialize(-insecure).
2022-07-22T10:30:28.760238 08:00 0 [Note] [MY-010949] [Server] Basedir set to /soft/mysql-8.0.29-linux-glibc2.17-x86_64-minimal/.
......

vim /etc/profile
#MYSQL_HOME
export MYSQL_HOME=/usr/local/mysql
export PATH=$PATH:$MYSQL_HOME/bin

source /etc/profile

mysqld_safe --defaults-file=/data/mysql/my.cnf &

mysqld --defaults-file=/data/mysql/my.cnf &

启动成功会有对应的日志。

连接数据库

[root@mysqldb_master logs]# mysql -S /data/mysql/mysql.sock -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.29 MySQL Community Server - GPL
Copyright (c) 2000, 2022, Oracle and/or its affiliates.
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> alter user user() identified by 'mysql';
Query OK, 0 rows affected (0.02 sec)

遇到的问题

[root@mysqldb_salve mysql]# /usr/local/mysql/bin/mysqld --defaults-file=/data/mysql/my.cnf --initialize
/usr/local/mysql/bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
[root@mysqldb_salve mysql]# dnf provides '*/libaio.so.1'
Last metadata expiration check: 1:41:20 ago on Fri 22 Jul 2022 09:13:49 AM CST.
libaio-0.3.112-1.el8.i686 : Linux-native asynchronous I/O access library
Repo : baseos
Matched from:
Filename : /usr/lib/libaio.so.1
libaio-0.3.112-1.el8.x86_64 : Linux-native asynchronous I/O access library
Repo : baseos
Matched from:
Filename : /usr/lib64/libaio.so.1
rpm -qf /lib64/libaio.so.1

[root@mysqldb_salve mysql]# /usr/local/mysql/bin/mysqld -S /tmp/mysql.sock -p
/usr/local/mysql/bin/mysql: error while loading shared libraries: libncurses.so.5: cannot open shared object file: No such file or directory
[root@mysqldb_salve mysql]# dnf provides '*/libncurses.so.5'
Last metadata expiration check: 1:44:42 ago on Fri 22 Jul 2022 09:13:49 AM CST.
ncurses-compat-libs-6.1-9.20180224.el8.i686 : Ncurses compatibility libraries
Repo : baseos
Matched from:
Filename : /usr/lib/libncurses.so.5
ncurses-compat-libs-6.1-9.20180224.el8.x86_64 : Ncurses compatibility libraries
Repo : baseos
Matched from:
Filename : /usr/lib64/libncurses.so.5
[root@mysqldb_salve mysql]# dnf install ncurses-compat-libs-6.1-9.20180224.el8.x86_64 -y

栏目热文

文档排行

本站推荐

Copyright © 2018 - 2021 www.yd166.com., All Rights Reserved.