Linux Centos 7 使用yum安装 mysql5.7 (实验成功)

第一部分:安装Mysql5.7

1.下载YUM库

shell > wget http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm
2.安装YUM库
shell > yum localinstall -y mysql57-community-release-el7-7.noarch.rpm
3.安装数据库
shell > yum install -y mysql-community-server

4.启动MySQL服务

shell > systemctl start mysqld.service

5.默认空密码

shell > mysql -uroot -p

6.重置root密码后重启mysql服务

shell > update mysql.user set authentication_string=password("yourpassword") where user="root" and Host="localhost";

shell > flush privileges;

shell > quit;

shell > systemctl restart mysqld;

如果手贱或者不知道啥原因出现如下问题:

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

请修改my.cnf,添加skip-grant-tables和skip-networking:

shell > vi /etc/my.cnf

[mysqld]

skip-grant-tables

skip-networking

重启mysql,然后重复以上修改密码步骤即可,记得修改完后,去掉my.cnf添加的两行。

第二部分:配置

1、添加远程登录用户(登入Mysql)
use mysql;
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '你的密码' WITH GRANT OPTION;
注:'%'代表任意地址,也可以指定IP
2、检查用户表,刷新内存权限
select host, user from user;
FLUSH PRIVILEGES;
Linux Centos 7 使用yum安装 mysql5.7 (实验成功)
3、设置防火墙(CentOS7 不推荐)
vi /etc/sysconfig/iptables
在-A RH-Firewall-1-INPUT -j REJECT –reject-with icmp-host-prohibited之前,添加
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
重启防火墙
service iptables restart
注:centos7使用的是firewall防火墙
  systemctl stop firewalld.service #停止
  systemctl disable firewalld.service #禁用
4、设置字符编码集和区分大小写
4.1修改mysql配置文件(设置字符编码集)
默认位置:/etc/my.cnf
进入etc文件夹>>vim my.cnf
[mysqld]
character-set-server=utf8
collation-server=utf8_general_ci
Linux Centos 7 使用yum安装 mysql5.7 (实验成功)
* systemctl restart mysql.service #重启MySQL
* 查看当前mysql运行状态
 mysql>status
 
参数说明:
haracter_set_client:客户端请求数据的字符集。
character_set_connection:从客户端接收到数据,然后传输的字符集。
character_set_database:默认数据库的字符集,无论默认数据库如何改变,都是这个字符集;如果没有默认数据库,使character_set_server指定的字符集,此参数无需设置。
character_set_filesystem:把操作系统上文件名转化成此字符集,即把character_set_client转换character_set_filesystem,默认binary即可。
character_set_results:结果集的字符集。
character_set_server:数据库服务器的默认字符集。
character_set_system:这个值总是utf8,不需要设置,存储系统元数据的字符集。
4.2修改mysql配置文件(设置区分大小写)
lower_case_table_names 参数详解:
0:区分大小写
1:不区分大小写
下面看下修改后的预览图:
Linux Centos 7 使用yum安装 mysql5.7 (实验成功)
以上是经过自己实践后记录的,若有疑问欢迎各位留言讨论!
上一篇:『编程题全队』Beta 阶段冲刺博客一


下一篇:『编程题全队』Alpha 阶段冲刺博客Day1