分布式系统-基础篇-CentOS7 安装mysql5.6

一、官网下载安装mysql-server

1、安装mysql

# wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm

# rpm -ivh mysql-community-release-el7-5.noarch.rpm

# yum install mysql-community-server

 

2、重启mysql服务

# service mysqld restart

3、登陆mysql

# mysql -u root

4、设置登陆密码

# set password for 'root'@'localhost' =password('ryqc2016RYQC');

二、配置mysql

1、编码

mysql配置文件为/etc/my.cnf

最后加上编码配置

# vi /etc/my.cnf

在文件末尾添加:

[mysql]
default-character-set =utf8

2、远程连接设置

把在所有数据库的所有表的所有权限赋值给位于所有IP地址的root用户。

mysql>grant all privileges on *.* to root@'%'identified by 'password';
 
如果是新用户而不是root,则要先新建用户
 
mysql> create user 'username'@'%' identified by 'password'; 
 
 

三、默认配置

<!--[if !supportLists]-->1.  <!--[endif]-->[client]  

<!--[if !supportLists]-->2.  <!--[endif]-->password        = 123456  

<!--[if !supportLists]-->3.  <!--[endif]-->port            = 3306  

<!--[if !supportLists]-->4.  <!--[endif]-->default-character-set=utf8  

<!--[if !supportLists]-->5.  <!--[endif]-->[mysqld]  

<!--[if !supportLists]-->6.  <!--[endif]-->port            = 3306  

<!--[if !supportLists]-->7.  <!--[endif]-->character_set_server=utf8  

<!--[if !supportLists]-->8.  <!--[endif]-->character_set_client=utf8  

<!--[if !supportLists]-->9.  <!--[endif]-->collation-server=utf8_general_ci  

<!--[if !supportLists]-->10.<!--[endif]-->#(注意linuxmysql安装完后是默认:表名区分大小写,列名不区分大小写; 0:区分大小写,1:不区分大小写)  

<!--[if !supportLists]-->11.<!--[endif]-->lower_case_table_names=1  

<!--[if !supportLists]-->12.<!--[endif]-->#(设置最大连接数,默认为 151MySQL服务器允许的最大连接数16384; )  

<!--[if !supportLists]-->13.<!--[endif]-->max_connections=1000  

<!--[if !supportLists]-->14.<!--[endif]-->[mysql]  

<!--[if !supportLists]-->15.<!--[endif]-->default-character-set = utf8  

四、开启防火墙

1、开启防火墙

firewall-cmd --zone=public --add-port=3306/tcp --permanent

2、重启防火墙

systemctl restart firewalld.service

 

猜你喜欢

转载自shusanzhan.iteye.com/blog/2356921