【MySQL yum安装】
- #### yum 安装
步骤: 关闭防火墙
systemctl stop firewalld
setenforce 0
- 优点:操作简单易用。不用单独下载,服务器可以联网且yum源没有问题即可(可以选择国内的163/阿里源)
步骤:官网下载mysql 安装包
wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
-
[root@192 yum.repos.d]# rpm -ivh mysql80-community-release-el7-3.noarch.rpm 解压安装包
步骤2:编写 mysql 配置文件下载5.7版本
[root@192 ~]# cd /etc/yum.repos.d/
[root@192 yum.repos.d]# vim mysql-community.repo
步骤:安装 下载
[root@192 yum.repos.d]# yum -y install mysql-community-server
查看mysql密码
grep password /var/log/mysqld.log yum安装密码都在这个目录下
yum安装存放文件的位置
#/var/lib/mysql #存放数据文件
#/usr/share/mysql #用于存放字符集,语言信息等
#/usr/bin/ #存放二进制命令
#/var/log/mysqld.log #错误日志文件存放
编译安装存文件位置
一般文件都是在你编译安装的存放目录以下
mysql安装完成没有密码
案例1:
如果首次启动,在日志文件中没有产生密码,进行以下操作
#systemctl stop mysqld 先停止mysql
#rm - rf /var/lib/mysql/* 删除这个日志目录下的东西,从新生成
#systemctl start mysqld 密码就会重新生成
mysq修改密码 方法
两种方式:
第一种:
[root ~]# mysql -uroot -p’woHtkMgau9,w’ #登录
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.27
…
mysql> alter user ‘root’@‘localhost’ identified by ‘QianFeng@123’; 修改方法
Query OK, 0 rows affected (0.01 sec)
mysql> flush privileges; //刷新权限表
Query OK, 0 rows affected (0.00 sec)
mysql> exit
Bye
[root ~]# mysql -uroot -p’QianFeng@123’ 新密码登录
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.27 MySQL Community Server (GPL)
…
mysql> exit
Bye
第二种:
#mysqladmin -u root -p’旧密码’ password ‘新密码’
注:修改密码必须大小写数字和特殊符号都有。
第三种:
修改mysql密码强度 企业不用
步骤:
[root@mysql-server ~]# vim /etc/my.cnf #在最后添加如下内容
validate_password=off 固定语法
[root@mysql-server ~]# systemctl restart mysqld #重启mysql生效
可以用第二种方式修改为简单的密码: