您的位置:首页 > 运维架构 > Linux

CentOS7使用yum安装MySQL5.6

2017-12-05 00:00 591 查看
1、先安装带有可用的mysql5系列社区版资源的rpm包

[root@iZ28gvqe4biZ ~]# rpm -Uvh http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm

获取http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
准备中... ################################# [100%]
正在升级/安装...
1:mysql-community-release-el7-5 ################################# [100%]

2、查看当前可用的mysql安装资源:

[root@iZ28gvqe4biZ ~]# yum repolist enabled | grep "mysql.-community."

mysql-connectors-community/x86_64 MySQL Connectors Community 17
mysql-tools-community/x86_64 MySQL Tools Community 31
mysql56-community/x86_64 MySQL 5.6 Community Server 199

3、一般来说,只要安装mysql-server跟mysql-client ,直接使用yum的方式安装MySQL

[root@iZ28gvqe4biZ ~]# yum -y install mysql-community-server

已加载插件:langpacks
正在解决依赖关系
--> 正在检查事务...

4、加入开机启动

[root@iZ28gvqe4biZ ~]# systemctl enable mysqld

5、启动mysql服务进程

[root@iZ28gvqe4biZ ~]# systemctl start mysqld

6、重置密码

[root@iZ28gvqe4biZ ~]# mysql_secure_installation

Enter current password for root (enter for none):
OK, successfully used password, moving on...

Set root password? [Y/n] y [设置root用户密码]
New password:
Re-enter new password:
Password updated successfully!

Remove anonymous users? [Y/n] y [删除匿名用户]

Disallow root login remotely? [Y/n] n [禁止root远程登录]

Remove test database and access to it? [Y/n] y [删除test数据库]

Reload privilege tables now? [Y/n] y [刷新权限]

7、进入mysql之后查看编码:

#mysql
mysql> show variables like 'character%';
下面是修改数据库编码:
修改my.cnf文件:
退出数据库:
mysql>\q
bye
关闭数据库:
#service mysqld stop
Stopping mysqld
之后修改my.cnf:
#vi /etc/my.cnf
分别在[client]和[mysqld]下面加入如下代码:
[client]
default_character_set=utf8
[mysqld]
collation_server=utf8_general_ci
character_set_server=utf8

重启mysql服务:
#service mysqld restart
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: