当前位置:网站首页>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!
边栏推荐
- Youxuan software appoints Huang Zhijun as the general manager of the company
- Plug in --- line segment sloth marking board + simple mathematical reasoning
- 11.书写规则-伪目标
- Tesla neural network model hydranet
- Cloud development workers must go to work fishing and paddling wechat applet source code
- 解读AI机器人养宠引领时尚潮流
- Idea replaces the contents of all files
- Jinshan cloud returns to Hong Kong for listing: Hong Kong stock rush of Chinese to B cloud manufacturers
- Library management system
- 这个博主,qt归类比较全,有空去学习总结,记录一下。
猜你喜欢

php 进程通信系列 (一) 命名管道

STP协议(生成树协议)

Flink内核源码(七)Flink SQL提交流程

Idea replaces the contents of all files

A good-looking IAPP donation list source code

《微信小程序-进阶篇》Lin-ui组件库源码分析-Button组件(二)

Flink生产环境经典问题汇总

Cloud development pocket toolbox wechat applet source code

Analyzing the subjective consciousness of emotional resonance between robots and human beings

Cloud development workers must go to work fishing and paddling wechat applet source code
随机推荐
ECCV 2022 | airdet: a small sample target detection method without fine tuning
双for循环
Which is a good automatic account distribution system?
QT屏幕自适应自动布局,拖动窗口自动变大变小(一)
第九天笔记
groupby 方法
C language: Little Lele and hexadecimal conversion
【报错】node:internal/modules/cjs/loader:936 【解决方法】
SQL查询数据之多表(关联)查询
Implementation principle of golang synergy
这个博主,qt归类比较全,有空去学习总结,记录一下。
Comic algorithm_ Xiaohuihui interview
QT screen adaptive automatic layout, drag the window to automatically grow larger and smaller (I)
DHCP protocol detailed analysis
[error reporting] node:internal/modules/cjs/loader:936 [solution]
Self organization is the two-way rush of managers and members
A good-looking IAPP donation list source code
Idea replaces the contents of all files
C语言:判断字母
Catchadmin practical tutorial (IV) implementation of relevant functions of table components