共计 2324 个字符,预计需要花费 6 分钟才能阅读完成。
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)
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/ |
+--------------------------+----------------------------+
更多 CentOS 相关信息见CentOS 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=14
本文永久更新链接地址:http://www.linuxidc.com/Linux/2016-06/132540.htm