当前位置:网站首页>Linux yum安装MySQL
Linux yum安装MySQL
2022-07-06 09:16:00 【@小蜗牛】
注意:只需要在master节点安装mysql
先装mysql源,再装mysql
目录
2.1切换root用户(密码:zkpk)
[[email protected] ~]# su root
2.2查看并卸载系统自带的mariadb-lib数据库
[[email protected] zkpk]# rpm -qa|grep mariadb
mariadb-libs-5.5.56-2.el7.x86_64
[[email protected] zkpk]# yum -y remove mariadb-libs-*
2.3添加MySQL yum源
注意:此步骤需要联网操作
2.3.1下载mysql源安装包
[[email protected] zkpk]# wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
2.3.2安装mysql源
[[email protected] zkpk]# yum -y localinstall mysql57-community-release-el7-8.noarch.rpm
2.3.3检查mysql源是否安装成功
[[email protected] zkpk]# yum repolist enabled | grep "mysql.*-community.*"
2.4安装MySQL
注意:安装mysql服务端时,客户端会作为依赖自动安装
[[email protected] zkpk]# yum -y install mysql-community-server
2.5启动MySQL服务
2.5.1命令
[[email protected] zkpk]# systemctl start mysqld
2.5.2查看MySQL的启动状态(出现图中绿色running字样表示成功)
[[email protected] zkpk]# systemctl status mysqld
2.6设置开机启动
[[email protected] zkpk]# systemctl enable mysqld
#重新载入 systemd,扫描新的或有变动的单元
[[email protected] zkpk]# systemctl daemon-reload
2.7修改root默认密码
2.7.1查看mysql安装生成的随机默认密码(/var/log/mysqld.log文件中)
[[email protected] zkpk]# grep 'temporary password' /var/log/mysqld.log
2.7.2登录mysql(密码为上图红框标注部分)
[[email protected] zkpk]# mysql -uroot -p
2.7.3修改mysql密码为“MyNewPass4!”(建议第一种)
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';
或者:
mysql> set password for 'root'@'localhost'=password('MyNewPass4!');
注意:mysql5.7默认安装了密码安全检查插件(validate_password),默认密码检查策略要求密码必须包含:大小写字母、数字和特殊符号,并且长度不能少于8位。否则会提示ERROR
1819 (HY000): Your password does not satisfy the current policy
requirements错误,如下图所示:
2.8修改mysql密码策略
2.8.1查看msyql密码策略的相关信息;退出mysql命令行
mysql> show variables like '%password%';
mysql> exit;
2.8.2关闭密码策略
2.8.2.1禁用mysql密码策略,向my.cnf文件末尾添加如下配置(/etc/my.cnf),保存、退出
[[email protected] zkpk]# vim /etc/my.cnf
validate_password = off
2.8.2.2重新启动mysql服务使配置生效:
[[email protected] zkpk]# systemctl restart mysqld
2.9修改root密码为zkpk
2.9.1登录mysql(密码:MyNewPass4!)
[[email protected] zkpk]# mysql -uroot -p
2.9.2修改mysql的root用户密码为zkpk(建议第一种)
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'zkpk';
或者
mysql> set password for 'root'@'localhost'=password('zkpk');
2.10添加zkpk用户并赋予远程登录权限,然后退出mysql命令行
mysql>grant all on *.* to [email protected]'%' identified by 'zkpk';
mysql>grant all on *.* to [email protected]'localhost' identified by 'zkpk';
mysql>grant all on *.* to [email protected]'master' identified by 'zkpk';
mysql>flush privileges;
mysql>exit;
2.11配置默认编码为utf8
2.11.1修改/etc/my.cnf配置文件,在[mysqld]下添加编码配置,即下图红框部分;保存、退出
[[email protected] zkpk]# vim /etc/my.cnf
[mysqld]
character_set_server=utf8
init_connect='SET NAMES utf8'
2.11.2重新启动mysql服务
[[email protected] zkpk]# systemctl restart mysqld
2.11.3查看数据库默认编码
2.11.3.1登录mysql(密码:zkpk)
[[email protected] zkpk]# mysql -uroot -p
2.11.3.2查看编码;然后退出mysql命令行
mysql> show variables like '%character%';
mysql> exit;
2.12查看防火墙是否关闭
2.12.1执行命令;若出现下红框dead字样,说明防火墙关闭
[[email protected] zkpk]# systemctl status firewalld
2.12.1若防火墙没有关闭,执行以下步骤。远程访问开放防火墙mysql的3306端口
[[email protected] zkpk]# firewall-cmd --add-port=3306/tcp
2.13MySQL的几个重要目录
配置文件:/etc/my.cnf
日志文件:/var/log/mysqld.log
服务启动脚本:/usr/lib/systemd/system/mysqld.service
socket文件:/var/run/mysqld/mysqld.pid
数据库目录 /var/lib/mysql/
配置文件 /usr/share/mysql(mysql.server命令及配置文件)
相关命令 /usr/bin(mysqladmin mysqldump等命令)
启动脚本 /etc/rc.d/init.d/(启动脚本文件mysql的目录)
边栏推荐
- Base de données Advanced Learning Notes - - SQL statements
- Learning question 1:127.0.0.1 refused our visit
- ES6 promise object
- Aborted connection 1055898 to db:
- Punctual atom stm32f103zet6 download serial port pin
- L2-007 family real estate (25 points)
- 分布式节点免密登录
- Composition des mots (sous - total)
- Codeforces Round #771 (Div. 2)
- 软件测试与质量学习笔记3--白盒测试
猜你喜欢
Mysql的索引实现之B树和B+树
[CDH] cdh5.16 configuring the setting of yarn task centralized allocation does not take effect
Software I2C based on Hal Library
Rhcsa certification exam exercise (configured on the first host)
【flink】flink学习
4、安装部署Spark(Spark on Yarn模式)
Vs2019 first MFC Application
Learn winpwn (3) -- sEH from scratch
Pytorch基础
[Blue Bridge Cup 2017 preliminary] grid division
随机推荐
Aborted connection 1055898 to db:
L2-006 tree traversal (25 points)
Learning question 1:127.0.0.1 refused our visit
[蓝桥杯2021初赛] 砝码称重
Pytorch基础
encoderMapReduce 随手记
2020网鼎杯_朱雀组_Web_nmap
Heating data in data lake?
Why can't STM32 download the program
Introduction and use of automatic machine learning framework (flaml, H2O)
C语言读取BMP文件
nodejs 详解
解决安装Failed building wheel for pillow
分布式节点免密登录
Password free login of distributed nodes
Error reporting solution - io UnsupportedOperation: can‘t do nonzero end-relative seeks
Case analysis of data inconsistency caused by Pt OSC table change
Error connecting to MySQL database: 2059 - authentication plugin 'caching_ sha2_ The solution of 'password'
[Kerberos] deeply understand the Kerberos ticket life cycle
Pytoch Foundation