千家信息网

centos7二进制安装mysql5.7.25的过程

发表于:2025-01-22 作者:千家信息网编辑
千家信息网最后更新 2025年01月22日,这篇文章主要介绍"centos7二进制安装mysql5.7.25的过程",在日常操作中,相信很多人在centos7二进制安装mysql5.7.25的过程问题上存在疑惑,小编查阅了各式资料,整理出简单好
千家信息网最后更新 2025年01月22日centos7二进制安装mysql5.7.25的过程

这篇文章主要介绍"centos7二进制安装mysql5.7.25的过程",在日常操作中,相信很多人在centos7二进制安装mysql5.7.25的过程问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答"centos7二进制安装mysql5.7.25的过程"的疑惑有所帮助!接下来,请跟着小编一起来学习吧!

一.安装前系统环境检查

1.关闭selinux

[root@mgr1 ~]# cat /etc/sysconfig/selinux# This file controls the state of SELinux on the system.# SELINUX= can take one of these three values:#     enforcing - SELinux security policy is enforced.#     permissive - SELinux prints warnings instead of enforcing.#     disabled - No SELinux policy is loaded.SELINUX=disabled# SELINUXTYPE= can take one of three values:#     targeted - Targeted processes are protected,#     minimum - Modification of targeted policy. Only selected processes are protected. #     mls - Multi Level Security protection.SELINUXTYPE=targeted

2.关闭防火墙

[root@mgr1 ~]# systemctl stop firewalld[root@mgr1 ~]# systemctl status firewalld● firewalld.service - firewalld - dynamic firewall daemon   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)   Active: inactive (dead) since Sat 2019-02-16 19:12:54 EST; 8s ago     Docs: man:firewalld(1)  Process: 7054 ExecStart=/usr/sbin/firewalld --nofork --nopid $FIREWALLD_ARGS (code=exited, status=0/SUCCESS) Main PID: 7054 (code=exited, status=0/SUCCESS)Feb 16 08:46:31 mgr1 systemd[1]: Starting firewalld - dynamic firewall daemon...Feb 16 08:46:33 mgr1 systemd[1]: Started firewalld - dynamic firewall daemon.Feb 16 19:12:52 mgr1 systemd[1]: Stopping firewalld - dynamic firewall daemon...Feb 16 19:12:54 mgr1 systemd[1]: Stopped firewalld - dynamic firewall daemon.

3.centos 7 io调度系统是deadline模式,ssd硬盘需要改为noop模式

[root@mgr1 ~]# cat /sys/block/sda/queue/schedulernoop [deadline] cfq

4.操作系统的限制

[root@mgr1 default]# ulimit -acore file size          (blocks, -c) 0data seg size           (kbytes, -d) unlimitedscheduling priority             (-e) 0file size               (blocks, -f) unlimitedpending signals                 (-i) 3795max locked memory       (kbytes, -l) 64max memory size         (kbytes, -m) unlimitedopen files                      (-n) 1024pipe size            (512 bytes, -p) 8POSIX message queues     (bytes, -q) 819200real-time priority              (-r) 0stack size              (kbytes, -s) 8192cpu time               (seconds, -t) unlimitedmax user processes              (-u) 3795virtual memory          (kbytes, -v) unlimitedfile locks                      (-x) unlimited

这里面最重要的两个参数是open files和max user processes

编辑/etc/security/limits.conf,加入下面的内容

*   soft   nproc  65535*   hard   nproc  65535*   soft   nofile 65535*   hard   nofile 65535

5.numa

6.创建用户组和用户

[root@mgr1 default]# groupadd mysql[root@mgr1 default]# [root@mgr1 default]# useradd -g mysql mysql -s /sbin/nologin[root@mgr1 default]#

7.做个软连接

[root@mgr1 default]# cd /usr/local[root@mgr1 local]# ls -ltrtotal 0drwxr-xr-x. 2 root root   6 Apr 11  2018 srcdrwxr-xr-x. 2 root root   6 Apr 11  2018 sbindrwxr-xr-x. 2 root root   6 Apr 11  2018 libexecdrwxr-xr-x. 2 root root   6 Apr 11  2018 lib64drwxr-xr-x. 2 root root   6 Apr 11  2018 libdrwxr-xr-x. 2 root root   6 Apr 11  2018 includedrwxr-xr-x. 2 root root   6 Apr 11  2018 gamesdrwxr-xr-x. 2 root root   6 Apr 11  2018 etcdrwxr-xr-x. 2 root root   6 Apr 11  2018 bindrwxr-xr-x. 5 root root  49 Feb 16 08:30 sharedrwxr-xr-x. 9 root root 129 Feb 16 18:58 mysql-5.7.25-linux-glibc2.12-i686[root@mgr1 local]# ln -s mysql-5.7.25-linux-glibc2.12-i686 mysql

8.授权

[root@mgr1 local]# chown mysql:mysql -R mysql

9.创建mysql数据库的数据目录(datadir)

[root@mgr1 /]# mkdir -p /data/mysql

10.给数据目录授权

[root@mgr1 /]# chown -R mysql:mysql /data/mysql

11.配置/etc/my.cnf文件

[client]port = 3306socket = /usr/local/mysql/mysql.sock[mysql]prompt="\u@db \R:\m:\s [\d]> "no-auto-rehash[mysqld]user=mysqlport=3306socket=/usr/local/mysql/mysql.sockserver_id=20gtid_mode=onenforce_gtid_consistency=onmaster_info_repository=tablerelay_log_info_repository=tablebinlog_checksum=nonelog_slave_updates=onlog-bin=/usr/local/mysql/log/mysql-binbinlog_format=rowbasedir=/usr/local/mysqldatadir=/data/mysqlperformance_schema=1character-set-server=utf8collation-server=utf8_binlog_timestamps=systemexplicit_defaults_for_timestamp=true####group replicationtransaction_write_set_extraction         =XXHASH64loose-group_replication_group_name       ='bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb'loose-group_replication_start_on_boot    =offloose-group_replication_local_address    ='192.168.44.132:33061'loose-group_replication_group_seeds      ='192.168.44.132:33061,192.168.44.133:33061,192.168.44.134:33061'loose-group_replication_bootstrap_group  =off

12.初始化

[root@mgr1 bin]# ./mysqld --defaults-file=/etc/my.cnf --basedir=/usr/local/mysql --datadir=/data/mysql/ --user=mysql --initialize

-bash: ./mysqld: /lib/ld-linux.so.2: bad ELF interpreter: No such file or directory

解决办法:

[root@mgr1 bin]# yum install glibc.i686

[root@mgr1 bin]# ./mysqld --defaults-file=/etc/my.cnf --basedir=/usr/local/mysql --datadir=/data/mysql/ --user=mysql --initialize

./mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory

解决办法:

yum -y install libaio.so.1

[root@mgr1 bin]# ./mysqld --defaults-file=/etc/my.cnf --basedir=/usr/local/mysql --datadir=/data/mysql/ --user=mysql --initialize

./mysqld: error while loading shared libraries: libnuma.so.1: cannot open shared object file: No such file or directory

yum install -y libnuma.so.1

[root@mgr1 bin]# ./mysqld --defaults-file=/etc/my.cnf --basedir=/usr/local/mysql --datadir=/data/mysql/ --user=mysql --initialize

./mysqld: error while loading shared libraries: libstdc++.so.6: cannot open shared object file: No such file or directory

yum install -y libstdc++.so.6

[root@mgr1 bin]# ./mysqld --defaults-file=/etc/my.cnf --basedir=/usr/local/mysql --datadir=/data/mysql/ --user=mysql --initialize

启动:

[root@mgr1 bin]# ./mysqld_safe --defaults-file=/etc/my.cnf &

[1] 7910

[root@mgr1 bin]# 2019-02-17T07:47:24.044846Z mysqld_safe Logging to '/data/mysql/error.log'.

2019-02-17T07:47:24.109848Z mysqld_safe Starting mysqld daemon with databases from /data/mysql

2019-02-17T07:47:26.264358Z mysqld_safe mysqld from pid file /data/mysql/mgr1.pid ended

查看初始化密码:

[root@mgr1 bin]# cat /data/mysql/error.log |grep password

2019-02-17T03:06:47.347886-05:00 1 [Note] A temporary password is generated for root@localhost: vjxL1c_F3*fd

登录:

[root@mgr1 bin]# ./mysql -uroot -p

修改密码:

root@db 03:10: [(none)]> set password='root123';

Query OK, 0 rows affected (0.00 sec)

root@db 03:12: [(none)]> alter user 'root'@'localhost' password expire never;

Query OK, 0 rows affected (0.00 sec)

root@db 03:13: [(none)]> flush privileges;

Query OK, 0 rows affected (0.00 sec)

设置环境变量

export PATH=$PATH:/usr/local/mysql/bin

让它生效

source /etc/profile

到此,关于"centos7二进制安装mysql5.7.25的过程"的学习就结束了,希望能够解决大家的疑惑。理论与实践的搭配能更好的帮助大家学习,快去试试吧!若想继续学习更多相关知识,请继续关注网站,小编会继续努力为大家带来更多实用的文章!

0