MySQL DBA 数据库安装(二)

下载软件

8.0

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

MD5: 60d18d1b324104c83da33dcd7a989816

5.7.26

MD5: 08a3b385db2f151598017b63fbcb6c43

wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.26-linux-glibc2.12-x86_64.tar.gz

5.6.44

MD5: 629f071f8154368e535464f7aa4a0659

wget https://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.44-linux-glibc2.12-x86_64.tar.g

检查软件安装以来,是否加载完类库

uname -a

cat /etc/redhat-release

tar -zxvf mysql-5.7.26-linux-glibc2.12-x86_64.tar.gz

cd mysql-5.7.26-linux-glibc2.12-x86_64

ldd bin/mysqld

源码编译--目的裁剪

linux环境检查

1.关闭numa

2.限制设置 /etc/security/limits.conf(文件句柄,进程数)  & 网络优化 (端口重用)

3.swap

4.io调度算法 deadline nloop

5.文件系统 xfs

6.selinux & iptables

安装准备

1.useradd -M -s /sbin/nologin mysql   -- mysql运行账号尽可能没有shell

或者如下创建账号

groupadd mysql

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

2./opt/mysql/mysql-5.7.26...

cd /usr/local/

ln -s /opt/mysql/mysql-5.7.26.xx mysql

3. /data    -- 单独挂载 系统故障不影响数据分区

mkdir /data/mysql/mysql3306/{data,logs,tmp} -p

chown -R mysql:mysql  /data/mysql/mysql3306

4./etc/my.cnf

文件替换操作 vi my.cnf

:%s/33306/3311/g

server_id 替换

5./usr/local/mysql/bin/mysqld --initialize

6.检查error logs  注意error

7./usr/local/mysql/bin/mysqld &

   /usr/local/mysql/bin/mysqld --defaults-file=/etc/my.cnf &

8.echo "export PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile

source /etc/profile

alter user user() identified by '';

低于5.7版本的安全加固

delete from mysql.user where user!='root' or host!='localhost';

truncate mysql.db;

drop database test;

注意:

authentication_plugin 'caching_sha2_password' cannot be loaded  -- 客户端版本问题

php链接8.0的问题

default_authentication_plugin=mysql_native_password

create user 'larry'@'%' identified with mysql_native_password by '';

重新创建账号即可

不同版本字符集问题 

原文地址:https://www.cnblogs.com/geek-ace/p/10960472.html