您好,登录后才能下订单哦!
这篇文章主要介绍“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/scheduler noop [deadline] cfq
4.操作系统的限制
[root@mgr1 default]# ulimit -a core file size (blocks, -c) 0 data seg size (kbytes, -d) unlimited scheduling priority (-e) 0 file size (blocks, -f) unlimited pending signals (-i) 3795 max locked memory (kbytes, -l) 64 max memory size (kbytes, -m) unlimited open files (-n) 1024 pipe size (512 bytes, -p) 8 POSIX message queues (bytes, -q) 819200 real-time priority (-r) 0 stack size (kbytes, -s) 8192 cpu time (seconds, -t) unlimited max user processes (-u) 3795 virtual memory (kbytes, -v) unlimited file 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 -ltr total 0 drwxr-xr-x. 2 root root 6 Apr 11 2018 src drwxr-xr-x. 2 root root 6 Apr 11 2018 sbin drwxr-xr-x. 2 root root 6 Apr 11 2018 libexec drwxr-xr-x. 2 root root 6 Apr 11 2018 lib64 drwxr-xr-x. 2 root root 6 Apr 11 2018 lib drwxr-xr-x. 2 root root 6 Apr 11 2018 include drwxr-xr-x. 2 root root 6 Apr 11 2018 games drwxr-xr-x. 2 root root 6 Apr 11 2018 etc drwxr-xr-x. 2 root root 6 Apr 11 2018 bin drwxr-xr-x. 5 root root 49 Feb 16 08:30 share drwxr-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 = 3306 socket = /usr/local/mysql/mysql.sock [mysql] prompt="\u@db \R:\m:\s [\d]> " no-auto-rehash [mysqld] user=mysql port=3306 socket=/usr/local/mysql/mysql.sock server_id=20 gtid_mode=on enforce_gtid_consistency=on master_info_repository=table relay_log_info_repository=table binlog_checksum=none log_slave_updates=on log-bin=/usr/local/mysql/log/mysql-bin binlog_format=row basedir=/usr/local/mysql datadir=/data/mysql performance_schema=1 character-set-server=utf8 collation-server=utf8_bin log_timestamps=system explicit_defaults_for_timestamp=true ####group replication transaction_write_set_extraction =XXHASH64 loose-group_replication_group_name ='bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb' loose-group_replication_start_on_boot =off loose-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的过程”的学习就结束了,希望能够解决大家的疑惑。理论与实践的搭配能更好的帮助大家学习,快去试试吧!若想继续学习更多相关知识,请继续关注亿速云网站,小编会继续努力为大家带来更多实用的文章!
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。