centos7安装mysql8.0.33

您所在的位置:网站首页 redhat71安装教程 centos7安装mysql8.0.33

centos7安装mysql8.0.33

2023-05-20 16:23| 来源: 网络整理| 查看: 265

       每次安装数据库都到处找帖子,找原来的笔记,把自己的安装过程记录下来,方便自己查看及童鞋们学习。

       

mysql下载

下载地址:

MySQL :: Download MySQL Community Server (Archived Versions)

1、修改句柄数,文件最后增加

vim /etc/security/limits.conf

* soft nofile 102400 * hard nofile 102400 * soft nproc 65535 * hard nproc 65535 * hard memlock 2048 * soft memlock 2048

2、修改权限、关闭防火墙

vim /etc/selinux/config

修改中SELINUX=enforcing 已经修改为 SELINUX=permissive

vim替换命令

:%s/SELINUX=enforcing/SELINUX=permissive/g

关闭防火墙:

systemctl stop firewalld.service systemctl disable firewalld.service systemctl status firewalld.service

3、centos安装

yum install -y gcc cc gcc-c++

也可以把常用的都安装一下

yum install -y gcc gcc-c++ vim zip unzip net-tools lrzsz wget 

最好重启一下

reboot

4、安装新版mysql之前,我们需要将系统自带的mariadb-lib卸载

查看:rpm -qa | grep -i mariadb     mariadb-libs-5.5.52-1.el7.x86_64 卸载:rpm -e --nodeps mariadb-libs-5.5.56-2.el7.x86_64 再查看,没有了就是卸载成功:rpm -qa | grep -i mariadb

5、创建mysql用户

groupadd mysql useradd -g mysql -m mysql -s /bin/false

6、上传mysql-8.0.33-1.el7.x86_64.rpm-bundle.tar并解压

解压: tar -xvf mysql-8.0.33-1.el7.x86_64.rpm-bundle.tar 安装: rpm -ivh mysql-community-common-8.0.33-1.el7.x86_64.rpm rpm -ivh mysql-community-client-plugins-8.0.33-1.el7.x86_64.rpm rpm -ivh mysql-community-libs-8.0.33-1.el7.x86_64.rpm rpm -ivh mysql-community-client-8.0.33-1.el7.x86_64.rpm rpm -ivh mysql-community-icu-data-files-8.0.33-1.el7.x86_64.rpm rpm -ivh mysql-community-server-8.0.33-1.el7.x86_64.rpm

7、创建安装目录及权限

mkdir -p /data/mysql/data chown mysql:mysql /data/mysql/ chown mysql:mysql /data/mysql/data chmod 777 -R /data/mysql/ chmod -R 777 /var/run/mysqld

8、编辑配置文件

vi /etc/my.cnf  删除原来的内容,直接拷贝以下内容:

[client] default-character-set = utf8mb4 [mysql] default-character-set = utf8mb4 [mysqld] character-set-client-handshake = FALSE character-set-server = utf8mb4 collation-server = utf8mb4_bin init_connect='SET NAMES utf8mb4' datadir=/data/mysql/data socket=/var/lib/mysql/mysql.sock symbolic-links=0 log-error=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid server-id=1 default-time-zone='+08:00' lower_case_table_names=1 transaction_isolation=READ-COMMITTED skip-name-resolve expire_logs_days=3 max_connections = 1250 max_user_connections=1000 max_connect_errors=100000 key_buffer_size = 256M max_allowed_packet = 16M table_open_cache = 512 log-bin=mysql-bin binlog_format = ROW slow-query-log=1 long_query_time =1 slow-query-log-file=/data/mysql/mysqld-slow.log #log-queries-not-using-indexes join_buffer_size = 1M read_buffer_size = 4M read_rnd_buffer_size = 8M innodb_buffer_pool_size = 2G innodb_autoextend_increment = 64M innodb_log_buffer_size = 8M innodb_log_file_size = 512M innodb_log_files_in_group = 3 innodb_flush_log_at_trx_commit = 1 innodb_max_dirty_pages_pct = 70 innodb_flush_method = O_DIRECT

9、-数据库初始化

mysqld --initialize --console --user=mysql

10、启动并修改默认密码

启动: service mysqld start 查看初始化的随机密码: grep 'temporary password' /var/log/mysqld.log 登录mysql,输入上面查看到的随机密码: mysql -u root -p 修改本地密码: mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '123456'; mysql> flush privileges;

11、如果需要其他机器远程访问,创建用户并赋权限:

mysql> create user root@'%' identified by '123456'; mysql> grant all privileges on *.* to root@'%' with grant option; -- 5.7 mysql> grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option; -- 8.0 mysql> alter user 'root'@'%' identified with mysql_native_password by '123456'; mysql> flush privileges;



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3