Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2912846
  • 博文数量: 199
  • 博客积分: 1400
  • 博客等级: 上尉
  • 技术积分: 4126
  • 用 户 组: 普通用户
  • 注册时间: 2008-07-06 19:06
个人简介

半个PostgreSQL DBA,热衷于数据库相关的技术。我的ppt分享https://pan.baidu.com/s/1eRQsdAa https://github.com/chenhuajun https://chenhuajun.github.io

文章分类

全部博文(199)

文章存档

2020年(5)

2019年(1)

2018年(12)

2017年(23)

2016年(43)

2015年(51)

2014年(27)

2013年(21)

2011年(1)

2010年(4)

2009年(5)

2008年(6)

分类: Mysql/postgreSQL

2016-05-06 17:16:00

1. 从官网下载mysql5.7的安装包

http://dev.mysql.com/downloads/mysql/
下载下面几个即可,其它的可选
                       
mysql-community-client-5.7.11-1.el6.x86_64.rpm
mysql-community-libs-5.7.11-1.el6.x86_64.rpm
mysql-community-common-5.7.11-1.el6.x86_64.rpm
mysql-community-server-5.7.11-1.el6.x86_64.rpm

下载后拷贝到目标机器的mysql5.7目录下

2.  安装mysql5.7

  1. cd mysql5.7
  2. rpm -ihv *.rpm --nodeps
注:我的环境不干净,装了多套MySQL。正常应该把上面的"--nodeps"去掉,或者用"yum install *.rpm"安装。


如果由于和已安装的mysql冲突失败,卸载冲突的旧版mysql再执行,比如:
  1. rpm -e mysql-libs-5.1.61 --nodeps
  2. rpm -e mysql-5.1.61 --nodeps

3. 根据环境修改配置文件

  1. vi /etc/my.cnf

4. 初始化数据库

  1. mysqld --initialize --user mysql

5. 启动数据库

  1. mysqld_safe &

6. 连接数据库并修改密码

  1. mysql -S /opt/mysql57_data/mysql.sock -uroot -pqXay8wk3RL*T -e "ALTER USER USER() IDENTIFIED BY 'mysql'"
上面假设数据目录为"/opt/mysql57_data",初始密码"qXay8wk3RL*T",这两项需要根据实际情况修改。
初始密码可以在错误日志里找到:

  1. vi /opt/mysql57_data/mysql-error.log
  2. ...
  3. 2016-05-06T08:37:29.767232Z 1 [Note] A temporary password is generated for root@localhost: qXay8wk3RL*T

7. 设置client配置文件

vi ~/.my.cnf
  1. [client]
  2. user = root
  3. password = mysql
  4. port=3306
  5. socket = /opt/mysql57_data/mysql.sock

8. 测试一下无密码登录

  1. [root@node1 ~]# mysql
  2. Welcome to the MySQL monitor. Commands end with ; or \g.
  3. Your MySQL connection id is 160
  4. Server version: 5.7.11-log MySQL Community Server (GPL)
  5. Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
  6. Oracle is a registered trademark of Oracle Corporation and/or its
  7. affiliates. Other names may be trademarks of their respective
  8. owners.
  9. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  10. mysql>
阅读(3491) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~