当前位置:网站首页>centos安装mysql8
centos安装mysql8
2022-07-29 02:33:00 【m0_67403188】
1.下载并安装 yum repostory
下载:
wget -i -c https://repo.mysql.com//mysql80-community-release-el7-1.noarch.rpm
安装myql:
yum -y install mysql80-community-release-el7-1.noarch.rpm
安装mysql服务:
yum -y install mysql-community-server
2.配置数据库:
2.1如果有需要可以设置u不区分大小写(编辑 /etc/my.cnf文件):
文件中添加如下配置:
lower_case_table_names=1 // 1:不敏感,0:敏感)
2.2启动mysql8
systemctl start mysqld.service
2.3查看mysql8运行状态
systemctl status mysqld.service
2.4设置密码
设置密码首先我们要知道root账户的初始密码使用以下命令查看:
grep "password" /var/log/mysqld.log

上图箭头中指示的就是初始密码,复制该密码,使用以下命令登录数据库:
mysql -uroot -p
注意:这时候用初始密码登录是无法做任何事的,需要先修改初始密码,修改初始密码如果密码不符合规则过于简单是会报错的,如果想设置个简单的密码,那第一次你还是先设置个比较复杂的,设置完以后再修改密码策略,这时候再次修改为简单的密码即可,具体操作如下:
2.4.1修改一个复杂的密码:
ALTER USER 'root'@'localhost' IDENTIFIED BY '你的复杂密码';
2.4.2查看密码策略:
SHOW VARIABLES LIKE 'validate_password%';

注意这里mysql8的密码策略是
validate_password.policy
而mysql5的时候密码策略是
validate_password_policy
2.4.3修改策略为低级:
set global validate_password.policy=LOW;
然后再按照2.4.1命令修改一个简单的密码即可
3.设置远程访问:
3.1开放防火墙3306端口
firewall-cmd --permanent --zone=public --add-port=3306/tcp
如果防火墙关闭状态,可以先打开
1> 查看防火墙状态:systemctl status firewalld
2>开启防火墙:systemctl start firewalld
开启防火墙以后再执行开放端口命令即可。
3.2刷新防火墙
firewall-cmd --reload
安装到此结束。
**最后:**如果你用navicat客户端登录可能会报错,因为密码认证方式不支持,默认是 caching_sha2_password,可以修改 /etc/my.cnf文件改变密码认证方式为mysql_native_password
在my.cnf文件的[mysqld]下面加上如下配置:
default_authentication_plugin=mysql_native_password
登录mysql
mysql -u root -p
查询用户信息:
select host, user, authentication_string, plugin from user;

上图中我们能看到相关信息,默认localhost,不支持所有ip访问,我们修改所有ip都允许,则把localhost改为%
update user set host='%' where user = 'root';
修改加密规则:
ALTER USER 'root'@'%' IDENTIFIED BY '登录密码' PASSWORD EXPIRE NEVER;
更新密码:
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '登录密码';
刷新权限:
flush privileges;
到此ok!
边栏推荐
- QT screen adaptive automatic layout, drag the window to automatically grow larger and smaller (I)
- Seed random seed
- OWT server source code analysis (4) -- video module analysis of mixer out
- Notes on the seventh day
- 明明开发薪资高,为什么我还是选了测试?
- Tesla neural network model hydranet
- 【OpenCV】使用OpenCV调用手机摄像头
- Summary of classic problems in Flink production environment
- 每周推荐短视频:如何让产品开发更加有效?
- idea配置web容器与war打包
猜你喜欢

Comic algorithm_ Xiaohuihui interview

DHCP protocol detailed analysis

Polygon zkevm - Introduction to HERMEZ 2.0

New UI Sifang aggregate payment system source code / new usdt withdrawal / latest update security upgrade to fix XSS vulnerability patch vulnerability

Analysis of Project-based Learning Creativity in steam Education

MongoDB索引 (3)

Some new ideas about time complexity

这个博主,qt归类比较全,有空去学习总结,记录一下。
![[error reporting] node:internal/modules/cjs/loader:936 [solution]](/img/73/849c58c814c1a47dff0cde0e365c75.png)
[error reporting] node:internal/modules/cjs/loader:936 [solution]

DataGrip 如何导出和恢复整个数据库数据,使用单个 SQL 文件
随机推荐
DHCP protocol detailed analysis
Jinshan cloud returns to Hong Kong for listing: Hong Kong stock rush of Chinese to B cloud manufacturers
冰冰学习笔记:运算符重载---日期类的实现
(作业)C语言:atoi和strncpy、strncat、strncmp的模拟实现
常用hooks总结
12.书写规则-静态模式
etcd实现大规模服务治理应用实战
Rocbos open source micro community light forum source code
A good-looking IAPP donation list source code
Flink kernel source code (VII) Flink SQL submission process
【报错】node:internal/modules/cjs/loader:936 【解决方法】
Polygon zkEVM——Hermez 2.0简介
11. Writing rules - pseudo target
瀚高数据库最佳实践配置工具HG_BP日志采集内容
11.书写规则-伪目标
Youxuan software appoints Huang Zhijun as the general manager of the company
QT screen adaptive automatic layout, drag the window to automatically grow larger and smaller (I)
Implement encapsulated public method global call in laravel framework
C language: Little Lele and Euclid
seed 随机种子