标签:开机启动 utf8 upload str date localhost lin cimage oca
1.下载yum源
shell> wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
2.安装yum源包
shell>yum localinstall mysql57-community-release-el7-8.noarch.rpm
3.检查mysql源是否安装成功
shell> yum repolist enabled | grep "mysql.*-community.*"
4.安装mysql
shell> yum install mysql-community-server
5.启动MySQL服务
shell> systemctl start mysqld
6.查看MySQL的启动状态
shell> systemctl status mysqld
7.开机启动
shell> systemctl enable mysqldshell> systemctl daemon-reload
8.修改root默认密码
mysql安装完成之后,在/var/log/mysqld.log文件中给root生成了一个默认密码。通过下面的方式找到root默认密码,然后登录mysql进行修改:
shell> grep ‘temporary password‘ /var/log/mysqld.log
![](//upload-images.jianshu.io/upload_images/3953109-255a8c0eb058ea53.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
shell> mysql -uroot -p
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错误,如下图所示:
![](//upload-images.jianshu.io/upload_images/3953109-2d42b91c038930db.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
通过msyql环境变量可以查看密码策略的相关信息:
mysql> show variables like ‘%password%‘;
![](//upload-images.jianshu.io/upload_images/3953109-7537b7a36ebc3357.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
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
MySQL官网密码策略详细说明:[http://dev.mysql.com/doc/refman/5.7/en/validate-password-options-variables.html#sysvar_validate_password_policy](http://www.cnblogs.com/baierfa/p/6688737.html#sysvar_validate_password_policy)
修改密码策略
在/etc/my.cnf文件添加validate_password_policy配置,指定密码策略
# 选择0(LOW),1(MEDIUM),2(STRONG)其中一种,选择2需要提供密码字典文件
validate_password_policy=0
如果不需要密码策略,添加my.cnf文件中添加如下配置禁用即可:
validate_password = off
重新启动mysql服务使配置生效:
systemctl restart mysqld
9.添加远程登录用户
默认只允许root帐户在本地登录,如果要在其它机器上连接mysql,必须修改root允许远程连接,或者添加一个允许远程连接的帐户,为了安全起见,我添加一个新的帐户:
mysql> GRANT ALL PRIVILEGES ON *.* TO ‘yangxin‘@‘%‘ IDENTIFIED BY ‘Yangxin0917!‘ WITH GRANT OPTION;
10.配置默认编码为utf8
修改/etc/my.cnf配置文件,在[mysqld]下添加编码配置,如下所示:
[mysqld]character_set_server=utf8 init_connect=‘SET NAMES utf8‘
重新启动mysql服务,查看[数据库](http://lib.csdn.net/base/14)默认编码如下所示:
![](//upload-images.jianshu.io/upload_images/3953109-0a831253ca2377b9.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
第三方依赖包所有节点都安装
yum install chkconfig python bind-utils psmisc libxslt zlib sqlite fuse fuse-libs redhat-lsb cyrus-sasl-plain cyrus-sasl-gssapi
注意这个地方依赖包不安装完下面启动集群的时候会死活启动不了的,这是血的教训啊!在hadoop1上准备mysql的jar包
[root@hadoop1]# mkdir -p /usr/share/java
修改jar包的名字,并拷贝到/usr/share/java/目录(下面会有截图说明为什么修改)
[root@hadoop1]# cp mysql-connector-java-5.1.36-bin.jar /usr/share/java/mysql-connector-java.jar
标签:开机启动 utf8 upload str date localhost lin cimage oca
原文地址:https://www.cnblogs.com/sdhzdtwhm/p/9644601.html