• ADADADADAD

    centos7二进制安装mysql5.7.25的过程[ mysql数据库 ]

    mysql数据库 时间:2024-11-28 13:03:06

    作者:文/会员上传

    简介:

    一.安装前系统环境检查1.关闭selinux[root@mgr1~]#cat/etc/sysconfig/selinux#ThisfilecontrolsthestateofSELinuxonthesystem.#SELINUX=cantakeoneofthesethreevalues:#enf

    以下为本文的正文内容,内容仅供参考!本站为公益性网站,复制本文以及下载DOC文档全部免费。

    一.安装前系统环境检查

    1.关闭selinux

    [root@mgr1~]#cat/etc/sysconfig/selinux#ThisfilecontrolsthestateofSELinuxonthesystem.#SELINUX=cantakeoneofthesethreevalues:#enforcing-SELinuxsecuritypolicyisenforced.#permissive-SELinuxprintswarningsinsteadofenforcing.#disabled-NoSELinuxpolicyisloaded.SELINUX=disabled#SELINUXTYPE=cantakeoneofthreevalues:#targeted-Targetedprocessesareprotected,#minimum-Modificationoftargetedpolicy.Onlyselectedprocessesareprotected.#mls-MultiLevelSecurityprotection.SELINUXTYPE=targeted

    2.关闭防火墙

    [root@mgr1~]#systemctlstopfirewalld[root@mgr1~]#systemctlstatusfirewalld●firewalld.service-firewalld-dynamicfirewalldaemonLoaded:loaded(/usr/lib/systemd/system/firewalld.service;enabled;vendorpreset:enabled)Active:inactive(dead)sinceSat2019-02-1619:12:54EST;8sagoDocs:man:firewalld(1)Process:7054ExecStart=/usr/sbin/firewalld--nofork--nopid$FIREWALLD_ARGS(code=exited,status=0/SUCCESS)MainPID:7054(code=exited,status=0/SUCCESS)Feb1608:46:31mgr1systemd[1]:Startingfirewalld-dynamicfirewalldaemon...Feb1608:46:33mgr1systemd[1]:Startedfirewalld-dynamicfirewalldaemon.Feb1619:12:52mgr1systemd[1]:Stoppingfirewalld-dynamicfirewalldaemon...Feb1619:12:54mgr1systemd[1]:Stoppedfirewalld-dynamicfirewalldaemon.

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

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

    4.操作系统的限制

    [root@mgr1default]#ulimit-acorefilesize(blocks,-c)0datasegsize(kbytes,-d)unlimitedschedulingpriority(-e)0filesize(blocks,-f)unlimitedpendingsignals(-i)3795maxlockedmemory(kbytes,-l)64maxmemorysize(kbytes,-m)unlimitedopenfiles(-n)1024pipesize(512bytes,-p)8POSIXmessagequeues(bytes,-q)819200real-timepriority(-r)0stacksize(kbytes,-s)8192cputime(seconds,-t)unlimitedmaxuserprocesses(-u)3795virtualmemory(kbytes,-v)unlimitedfilelocks(-x)unlimited

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

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

    *softnproc65535*hardnproc65535*softnofile65535*hardnofile65535

    5.numa

    6.创建用户组和用户

    [root@mgr1default]#groupaddmysql[root@mgr1default]#[root@mgr1default]#useradd-gmysqlmysql-s/sbin/nologin[root@mgr1default]#

    7.做个软连接

    [root@mgr1default]#cd/usr/local[root@mgr1local]#ls-ltrtotal0drwxr-xr-x.2rootroot6Apr112018srcdrwxr-xr-x.2rootroot6Apr112018sbindrwxr-xr-x.2rootroot6Apr112018libexecdrwxr-xr-x.2rootroot6Apr112018lib64drwxr-xr-x.2rootroot6Apr112018libdrwxr-xr-x.2rootroot6Apr112018includedrwxr-xr-x.2rootroot6Apr112018gamesdrwxr-xr-x.2rootroot6Apr112018etcdrwxr-xr-x.2rootroot6Apr112018bindrwxr-xr-x.5rootroot49Feb1608:30sharedrwxr-xr-x.9rootroot129Feb1618:58mysql-5.7.25-linux-glibc2.12-i686[root@mgr1local]#ln-smysql-5.7.25-linux-glibc2.12-i686mysql

    8.授权

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

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

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

    10.给数据目录授权

    [root@mgr1/]#chown-Rmysql: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####groupreplicationtransaction_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的过程.docx

    将本文的Word文档下载到电脑

    推荐度:

    下载
    热门标签: mysqlcentos