当前位置: 首页 > news >正文

Redhat7.6安装MySQL8.0.23——二进制安装

操作系统版本:Red Hat Enterprise Linux 7.6 

MySQL版本:mysql-8.0.23-el7-x86_64.tar.gz


groupadd mysql
useradd -g mysql mysql
echo 'mysql:mysql' | chpasswd


cd /usr/local/
tar -zxvf mysql-8.0.23-el7-x86_64.tar.gz
mv mysql-8.0.23-el7-x86_64 mysql

chown -R mysql:mysql mysql

cd mysql

初始化:

vi /etc/my.cnf

[mysqld]
basedir = /usr/local/mysql
datadir = /data
log_error = /data/mysql-error.log
port = 3306
socket = /data/mysqld.sock
pid_file = /data/mysqld.pid

character-set-server=utf8
lower_case_table_names=1
max_connections=1000
sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION'

[mysql]
default-character-set=utf8

[client]
default-character-set=utf8

/usr/local/mysql/bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/data

[root@mysql data]# more mysql-error.log 
2021-04-15T02:39:36.209816Z 0 [System] [MY-013169] [Server] /usr/local/mysql/bin/mysqld (mysqld 8.0.23) initializing of server in progress as process 12748
2021-04-15T02:39:36.212809Z 0 [Warning] [MY-013242] [Server] --character-set-server: 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for
 UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
2021-04-15T02:39:36.231253Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2021-04-15T02:39:37.003852Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2021-04-15T02:39:38.780676Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: 3dpGwPtaR5*>


mysql启动服务:

vi /etc/systemd/system/mysqld.service


内容如下:(缺点:当kill掉时,无法自动启动恢复)

[Unit]
Description=MySQL Server
Documentation=man:mysqld(8)
Documentation=http://dev.mysql.com/doc/refman/en/using-systemd.html
Documentation=https://www.freedesktop.org/software/systemd/man/systemd.unit.html
After=network.target
After=syslog.target
[Install]
WantedBy=multi-user.target
[Service]
User=mysql
Group=mysql
LimitNOFILE = 5000
ExecStart=/usr/local/mysql/bin/mysqld --defaults-file=/etc/my.cnf

systemctl start mysqld.service
systemctl status mysqld.service

配置环境变量:
vi /etc/profile

追加内容如下:
MYSQL_HOME=/usr/local/mysql
export PATH=.:$PATH:$MYSQL_HOME/bin


修改root初始密码:
ln -s /data/mysqld.sock /tmp/mysql.sock
这样就不用在登陆的时候指定sock文件了

mysql -u root -p 

3dpGwPtaR5*>


alter user root@'localhost' identified by 'root';

flush privileges;

配置mysql远程登录:

关闭防火墙或开放MySQL端口
查看允许访问MySQL的用户和地址

select user,host from mysql.user;

create user 'root'@'%' identified by 'root';

grant all privileges on *.* to 'root'@'%';

flush privileges;

--------------------------------------------------------------------------
在使用 Navicat for Mysql连接mysql 8.0时会报如下错误:

mysql> authentication plugin 'caching_sha2_password' cannot be loaded;

mysql8.0 引入了新特性 caching_sha2_password;这种密码加密方式客户端不支持;客户端支持的是mysql_native_password 这种加密方式;

我们可可以查看mysql 数据库中user表的 plugin字段;


mysql> use mysql;
mysql> select user,plugin from user where user='root';
+------+-----------------------+
| user | plugin                |
+------+-----------------------+
| root | caching_sha2_password |
| root | caching_sha2_password |
+------+-----------------------+
2 rows in set (0.00 sec)

可以使用命令将他修改成mysql_native_password加密模式
alter user 'root'@'%' identified with mysql_native_password by 'root';
select host,user,plugin from user;
 

相关文章:

  • 故障处理:一次由于盘符变化导致的Oracle 19.7集群无法启动
  • 一次由于SQL Server BUG引起的数据库AlwaysOn主从切换故障分析处理
  • Linux(centos)中使用源码安装PostGIS
  • SQL Server Always ON 数据同步原理
  • RFS(一)就从这里开始吧
  • 谈谈安装MYSQL ODBC遇到的报错(Error 1918)
  • RFS( 二 )----一些常用的快捷键
  • RFS(三)----解决x64机器上IE11版本使用IEDriverServer在输入英文/数字很慢的问题
  • RFS(四)${EMPTY}参数
  • RFS(五)AutoItLibrary库RUN关键字的用法及附加的其他关键字
  • LoadRunner(一)LR文件整个读取和计算长度
  • LoadRunner(二)LR参数文件多列的使用和局部变量超长的问题解决方法
  • 文件批量Base64编码工具
  • Windows下批处理方式压缩文件夹为tar.gz的方法
  • RFS(六)Open Browser后,页面显示This is the initial start page for the WebDriver server.的解决办法
  • ES6 ...操作符
  • JavaScript设计模式系列一:工厂模式
  • OSS Web直传 (文件图片)
  • PHP变量
  • Sublime Text 2/3 绑定Eclipse快捷键
  • vue学习系列(二)vue-cli
  • 分享几个不错的工具
  • 那些被忽略的 JavaScript 数组方法细节
  • 探索 JS 中的模块化
  • 【云吞铺子】性能抖动剖析(二)
  • 交换综合实验一
  • ​一文看懂数据清洗:缺失值、异常值和重复值的处理
  • # Swust 12th acm 邀请赛# [ E ] 01 String [题解]
  • (C#)if (this == null)?你在逗我,this 怎么可能为 null!用 IL 编译和反编译看穿一切
  • (SpringBoot)第二章:Spring创建和使用
  • (黑客游戏)HackTheGame1.21 过关攻略
  • (汇总)os模块以及shutil模块对文件的操作
  • (数据结构)顺序表的定义
  • (转)EOS中账户、钱包和密钥的关系
  • (转)shell中括号的特殊用法 linux if多条件判断
  • .bat批处理(九):替换带有等号=的字符串的子串
  • .gitattributes 文件
  • .NET CORE使用Redis分布式锁续命(续期)问题
  • .net6解除文件上传限制。Multipart body length limit 16384 exceeded
  • .Net转Java自学之路—SpringMVC框架篇六(异常处理)
  • /var/lib/dpkg/lock 锁定问题
  • @SpringBootApplication 包含的三个注解及其含义
  • @transactional 方法执行完再commit_当@Transactional遇到@CacheEvict,你的代码是不是有bug!...
  • [120_移动开发Android]008_android开发之Pull操作xml文件
  • [20150321]索引空块的问题.txt
  • [2023-年度总结]凡是过往,皆为序章
  • [C++] sqlite3_get_table 的使用
  • [CDOJ 838]母仪天下 【线段树手速练习 15分钟内敲完算合格】
  • [C语言]——C语言常见概念(1)
  • [Everyday Mathematics]20150130
  • [flink总结]什么是flink背压 ,有什么危害? 如何解决flink背压?flink如何保证端到端一致性?
  • [luoguP1666] 前缀单词(DP)
  • [Oh My C++ Diary]带参数的main()函数
  • [PHP] 算法-字符串的左循环的PHP实现
  • [Python]`threading.local`创建线程本地数据