承接国内外服务器租用托管、定制开发、网站代运营、网站seo优化托管接单、网站代更新,新老站点皆可!!咨询QQ:3787320601

一步一步教你怎样在RHEL/CentOS上的安装MySQL 5.7

管理员 2023-09-13 08:16:50 互联网圈 0 ℃ 0 评论 2583字 收藏

一步一步教你怎样在RHEL/CentOS上的安装MySQL 5.7

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

http://dev.mysql.com/downloads/mysql/
下载下面几个便可,其它的可选

mysql-community-client⑸.7.11⑴.el6.x86_64.rpm
mysql-community-libs⑸.7.11⑴.el6.x86_64.rpm
mysql-community-common⑸.7.11⑴.el6.x86_64.rpm
mysql-community-server⑸.7.11⑴.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⑸.1.61 –nodeps
  2. rpm -e mysql⑸.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. 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>

文章来源:丸子建站

文章标题:一步一步教你怎样在RHEL/CentOS上的安装MySQL 5.7

https://www.wanzijz.com/view/79343.html

X

截屏,微信识别二维码

微信号:weimawl

(点击微信号复制,添加好友)

打开微信