Toggle navigation
主页
English
K8S
Golang
Guitar
About Me
归档
标签
Welcome to Sanger's Blog!
mysql 8安装
无
2023-11-15 17:00:45
20
0
0
sanger
[TOC] # 概述 环境:centos 7.x(实际是 Alibaba Cloud Linux (Aliyun Linux) 2.1903 LTS (Hunting Beagle)) 单数据节点,非集群方式 # 准备 ``` #先看看有没有mysql的yum包 yum repolist all | grep mysql #如果没有下载mysql8的rpm wget https://repo.mysql.com//mysql80-community-release-el7-11.noarch.rpm # 安装rpm包,此步骤在/etc/yum.repos.d 下生成mysql8相应的repo文件 yum install mysql80-community-release-el7-11.noarch.rpm # 查看文件是否存在 ls /etc/yum.repos.d/ # 更新yum repo看看是否有mysql8的包 # 此repo 默认mysql80是enable的,安装时默认会安装mysql80 yum repolist all | grep mysql # 清理yum缓存并重新更新 yum clean all && yum makecache yum repolist all | grep mysql ``` # 安装 ``` # 直接安装,安装时看看版本是不是mysq80 yum install mysql-community-server ``` # 配置 > /etc/my.cnf 默认配置,无更改 ``` # For advice on how to change settings please see # http://dev.mysql.com/doc/refman/8.0/en/server-configuration-defaults.html [mysqld] # # Remove leading # and set to the amount of RAM for the most important data # cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%. # innodb_buffer_pool_size = 128M # # Remove the leading "# " to disable binary logging # Binary logging captures changes between backups and is enabled by # default. It's default setting is log_bin=binlog # disable_log_bin # # Remove leading # to set options mainly useful for reporting servers. # The server defaults are faster for transactions and fast SELECTs. # Adjust sizes as needed, experiment to find the optimal values. # join_buffer_size = 128M # sort_buffer_size = 2M # read_rnd_buffer_size = 2M # # Remove leading # to revert to previous value for default_authentication_plugin, # this will increase compatibility with older clients. For background, see: # https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_default_authentication_plugin # default-authentication-plugin=mysql_native_password datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock log-error=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid ``` # 启动 ``` systemctl start mysqld systemctl enable mysqld # 查看端口是否监听 netstat -tpnl ``` # 登录 ``` # 默认密码,第一次登录后必须更改 grep 'temporary password' /var/log/mysqld.log mysql -uroot -p ``` # 创建admin管理账号 ``` #更改mysql root密码后才能操作,root账户默认不能在%登录,只能在localhost登录 CREATE USER 'admin'@'%' IDENTIFIED WITH mysql_native_password BY 'xxxxxx'; GRANT ALL PRIVILEGES ON *.* TO 'admin'@'%' with GRANT OPTION; #刷新权限 FLUSH PRIVILEGES; ``` # 创建公共账号(仅用于开发测试环境,无DROP权限) ``` CREATE USER 'dev'@'%' IDENTIFIED WITH mysql_native_password BY 'xxxxxx'; GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, RELOAD, PROCESS, REFERENCES, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, EVENT, TRIGGER ON *.* TO 'dev'@'%'; #刷新权限 FLUSH PRIVILEGES; # 临时加DROP权限 GRANT DROP ON *.* TO 'dev'@'%'; # 撤销DROP权限 REVOKE DROP ON *.* FROM 'dev'@'%'; ``` # 创建同步账号 ``` CREATE USER 'syncer'@'%' IDENTIFIED WITH mysql_native_password BY 'xxxxxx'; GRANT SELECT,SHOW VIEW, RELOAD, REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO 'syncer'; #刷新权限 FLUSH PRIVILEGES; ```
上一篇:
elasticsearch 6.x 安装
下一篇:
redis 5.x 安装
0
赞
20 人读过
新浪微博
微信
更多分享
腾讯微博
QQ空间
人人网
文档导航