Centos 安装mysql5.7

1. 从mysql的官网下载mysql57-community-release-el6-8.noarch.rpm

2. 安装第一步下载的rpm

rpm -ivh mysql57-community-release-el6-8.noarch.rpm

3. 安装完成之后,我们发现在/etc/yum.repos.d目录下新增了两个文件:其中第二文件记录了mysql的源信息。

1 mysql-community.repo
2 mysql-community-source.repo

4. 查看可用的mysql安装源

 yum repolist enabled | grep mysql
 
1 mysql-connectors-community  MySQL Connectors Community                       21
2 mysql-tools-community       MySQL Tools Community                            24
3 mysql57-community           MySQL 5.7 Community Server                       56

5. 使用yum安装mysql(自动解决依赖问题,并安装了其他相关包)(如果需要保存下载的包,则修改/etc/yum.conf,将 

   keepcache=0 改为keepcache=1)

yum install mysql-community-server

Installing:

 mysql-community-libs            i686     5.7.13-1.el6            mysql57-community     2.0 M

     replacing  mysql-libs.i686 5.1.73-3.el6_5

 mysql-community-libs-compat     i686     5.7.13-1.el6            mysql57-community     1.6 M

     replacing  mysql-libs.i686 5.1.73-3.el6_5

 mysql-community-server          i686     5.7.13-1.el6            mysql57-community     140 M

Installing for dependencies:

 mysql-community-client          i686     5.7.13-1.el6            mysql57-community      22 M

 mysql-community-common          i686     5.7.13-1.el6            mysql57-community     327 k

Updating for dependencies:

 postfix                         i686     2:2.6.6-6.el6_7.1       base                  2.0 M


Transaction Summary

==============================================================================================

Install       5 Package(s)

Upgrade       1 Package(s)

6 .安装完成之后,查看mysql服务的状态

 sudo service mysqld status
 
 mysqld (pid  26422) is running...

7. 停止mysql服务,然后以安全模式启动mysql。

1 sudo service mysql stop
2 sudo mysqld_safe --skip-grant-tables --skip-networking &

8. 无密码登陆root, 设置root密码

1 mysql -u root
2 
3 
4 mysql> use mysql;
5 mysql>update user set authentication_string=password('12345678') where user='root';
6 mysql> flush privileges;

9. 修改字符集为utf8

vim /etc/my.cnf

在[mysqld]部分添加:
character-set-server=utf8

在文件末尾新增[client]段,在[client]段添加:
default-character-set=utf8

10. 查看字符

show variables like "%character%";

+--------------------------+----------------------------+
| Variable_name            | Value                      |
+--------------------------+----------------------------+
| character_set_client     | utf8                       |
| character_set_connection | utf8                       |
| character_set_database   | utf8                       |
| character_set_filesystem | binary                     |
| character_set_results    | utf8                       |
| character_set_server     | utf8                       |
| character_set_system     | utf8                       |
| character_sets_dir       | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+

 

 

 

 

posted on 2016-06-21 22:12  Mrs.Totoro  阅读(2058)  评论(0编辑  收藏  举报

导航