centos7.3+nginx1.8+php7.1+mysql5.7 安装(三安装mysql)
2017-06-11 19:57
281 查看
1、配置YUM源
在MySQL官网中下载YUM源rpm安装包:http://dev.mysql.com/downloads/repo/yum/ # 下载mysql源安装包 shell> wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm # 安装mysql源 shell> yum localinstall mysql57-community-release-el7-8.noarch.rpm1
2
3
4
1
2
3
4
检查mysql源是否安装成功
shell> yum repolist enabled | grep "mysql.*-community.*"1
1
看到上图所示表示安装成功。
可以修改
vim /etc/yum.repos.d/mysql-community.repo源,改变默认安装的mysql版本。比如要安装5.6版本,将5.7源的enabled=1改成enabled=0。然后再将5.6源的enabled=0改成enabled=1即可。改完之后的效果如下所示:
2、安装MySQL
shell> yum install mysql-community-server1
1
3、启动MySQL服务
shell> systemctl start mysqld1
1
查看MySQL的启动状态
shell> systemctl status mysqld ● mysqld.service - MySQL Server Loaded: loaded (/usr/lib/systemd/system/mysqld.service; disabled; vendor preset: disabled) Active: active (running) since 五 2016-06-24 04:37:37 CST; 35min ago Main PID: 2888 (mysqld) CGroup: /system.slice/mysqld.service └─2888 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid 6月 24 04:37:36 localhost.localdomain systemd[1]: Starting MySQL Server... 6月 24 04:37:37 localhost.localdomain systemd[1]: Started MySQL Server.1
2
3
4
5
6
7
8
9
10
1
2
3
4
5
6
7
8
9
10
4、开机启动
shell> systemctl enable mysqld shell> systemctl daemon-reload1
2
1
2
5、修改root本地登录密码
mysql安装完成之后,在/var/log/mysqld.log文件中给root生成了一个默认密码。通过下面的方式找到root默认密码,然后登录mysql进行修改:shell> grep 'temporary password' /var/log/mysqld.log1
1
shell> mysql -uroot -p mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';1
2
1
2
或者
mysql> set password for 'root'@'localhost'=password('MyNewPass4!');1
1
注意:mysql5.7默认安装了密码安全检查插件(validate_password),默认密码检查策略要求密码必须包含:大小写字母、数字和特殊符号,并且长度不能少于8位。否则会提示ERROR 1819 (HY000): Your password does not satisfy the current policy requirements错误,如下图所示:
通过msyql环境变量可以查看密码策略的相关信息:
mysql> show variableslike '%password%';1
1
validate_password_policy:密码策略,默认为MEDIUM策略
validate_password_dictionary_file:密码策略文件,策略为STRONG才需要
validate_password_length:密码最少长度
validate_password_mixed_case_count:大小写字符长度,至少1个
validate_password_number_count :数字至少1个
validate_password_special_char_count:特殊字符至少1个
上述参数是默认策略MEDIUM的密码检查规则。
共有以下几种密码策略:
策略 | 检查规则 |
---|---|
0 or LOW | Length |
1 or MEDIUM | Length; numeric, lowercase/uppercase, and special characters |
2 or STRONG | Length; numeric, lowercase/uppercase, and special characters; dictionary file |
修改密码策略
在/etc/my.cnf文件添加validate_password_policy配置,指定密码策略# 选择0(LOW),1(MEDIUM),2(STRONG)其中一种,选择2需要提供密码字典文件 validate_password_policy=01
2
1
2
如果不需要密码策略,添加my.cnf文件中添加如下配置禁用即可:
validate_password = off1
1
重新启动mysql服务使配置生效:
systemctl restart mysqld1
1
6、添加远程登录用户
默认只允许root帐户在本地登录,如果要在其它机器上连接mysql,必须修改root允许远程连接,或者添加一个允许远程连接的帐户,为了安全起见,我添加一个新的帐户:mysql> GRANT ALL PRIVILEGES ON *.* TO 'yangxin'@'%' IDENTIFIED BY 'Yangxin0917!' WITH GRANT OPTION;1
1
7、配置默认编码为utf8
修改/etc/my.cnf配置文件,在[mysqld]下添加编码配置,如下所示:[client] default-character-set = utf8mb4 [mysql] default-character-set = utf8mb4
[mysqld] character-set-client-handshake = FALSE character-set-server = utf8mb4 collation-server = utf8mb4_general_ci init_connect='SET NAMES utf8mb4'1
2
3
1
2
3
重新启动mysql服务,查看数据库默认编码如下所示:
//数据库字符集等
show variables
like'
character
%';
//排序字符集
show variables
like '
collation
%';
[/code]
默认配置文件路径:
配置文件:/etc/my.cnf
日志文件:/var/log//var/log/mysqld.log
服务启动脚本:/usr/lib/systemd/system/mysqld.service
socket文件:/var/run/mysqld/mysqld.pid
相关文章推荐
- centos7.3+nginx1.8+php7.1+mysql5.7 安装(准备工作)
- centos7.3+nginx1.8+php7.1+mysql5.7 安装(二安装php)
- centos7.3+nginx1.8+php7.1+mysql5.7 安装(一安装nginx)
- [macOS] macOS下,VirtualBox安装CentOS7.4, 搭建nginx, mysql, PHP5.6&PHP7.1
- WordPress 4.8 安装配置教程 (基于 centos 7.3, php 7.0, mysql 5.7.19, nginx 1.12.1)
- CentOS7.1安装配置Apache+PHP+MySQL+PHPMyAdmin+Zend debugger
- How to install Apache, PHP 7.1 and MySQL on CentOS 7.3 (LAMP)
- CentOS7.3(1611) 安装 nginx+php7.2+mysql5.7
- Centos7.3_64位安装Apache2.4_mysql5.7_php5.4(阿里云LAMP php环境搭建图文教程)
- centos7.3 下 安装lnmp(nginx1.10、mysql5.7、php7.0.20)
- centos7.1 yum 安装 MySQL5.7 和 PHP5.6
- LNMP源码编译过程 CentOS-7.3+Nginx-1.11+MySQL-5.7+php-7.1
- CentOS 7.3+PHP7.2+mysql5.7+Workerman3安装
- 基于centos7.3 redhat7.3安装LAMP(php7.0 php7.1)生产环境实践
- CentOS 5.5 中 Apache、MySQL、PHP 的安装信息
- CentOS 5.3上yum安装Apache+php+Mysql+phpMyAdmin
- CentOS 5.5 中 Apache、MySQL、PHP 的安装信息
- CentOS 5.4 服务器配置 yum安装Apache+php+Mysql+phpmyadmin
- CentOS 5.4 服务器配置 yum安装Apache+php+Mysql
- CentOS+Apache+Mysql+Php安装及优化配置小记