首页 > 代码库 > 在centos 7下安装mysql 5.7.17
在centos 7下安装mysql 5.7.17
首先查看系统有没有安装mysql
[root@VM_167_102_centos ~]# rpm -qa|grep mysql [root@VM_167_102_centos ~]#
结果发现没有,那么我们先下载mysql得rpm包
首先下载server
[root@VM_167_102_centos mysql]# wget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-community-server-5.7.17-1.el7.x86_64.rpm --2017-04-02 17:51:11-- https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-community-server-5.7.17-1.el7.x86_64.rpm Resolving cdn.mysql.com (cdn.mysql.com)... 23.219.134.205 Connecting to cdn.mysql.com (cdn.mysql.com)|23.219.134.205|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 169496800 (162M) [application/x-redhat-package-manager] Saving to: ‘mysql-community-server-5.7.17-1.el7.x86_64.rpm‘ 0% [ ] 593,988 65.3KB/s eta 42m 14s
然后下载client
wget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-community-client-5.7.17-1.el7.x86_64.rpm --2017-04-02 17:55:12-- https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-community-client-5.7.17-1.el7.x86_64.rpm Resolving cdn.mysql.com (cdn.mysql.com)... 23.211.97.88 Connecting to cdn.mysql.com (cdn.mysql.com)|23.211.97.88|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 25037548 (24M) [application/x-redhat-package-manager] Saving to: ‘mysql-community-client-5.7.17-1.el7.x86_64.rpm‘ 7% [=======> ] 1,762,140 60.9KB/s eta 3m 50s
然后先安装server
[root@VM_167_102_centos mysql]# rpm -ivh mysql-community-server-5.7.17-1.el7.x86_64.rpm --nodeps --force warning: mysql-community-server-5.7.17-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY Preparing... ################################# [100%] Updating / installing... 1:mysql-community-server-5.7.17-1.e################################# [100%]
然后安装client
[root@VM_167_102_centos mysql]# rpm -ivh mysql-community-client-5.7.17-1.el7.x86_64.rpm --nodeps warning: mysql-community-client-5.7.17-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY Preparing... ################################# [100%] Updating / installing... 1:mysql-community-client-5.7.17-1.e################################# [100%]
然后启动mysql服务
[root@VM_167_102_centos mysql]# service mysqld start Redirecting to /bin/systemctl start mysqld.service [root@VM_167_102_centos mysql]#
获取临时密码
[root@VM_167_102_centos mysql]# grep ‘temporary password‘ /var/log/mysqld.log 2017-04-02T14:55:58.589047Z 1 [Note] A temporary password is generated for root@localhost: k1pki)rKa6HL
然后使用临时密码进入mysql修改密码
[root@VM_167_102_centos mysql]# mysql -uroot -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 5 Server version: 5.7.17 Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement. mysql>
然后进入etc/my.cnf在[mysqld]下添加一行如下代码
skip-grant-tables
然后在使用刚才得临时密码进入mysql修改root密码
mysql> update mysql.user set authentication_string=password(‘root‘) where user=‘root‘ and Host = ‘localhost‘; Query OK, 1 row affected, 1 warning (0.00 sec)
然后再把my.cnf文件下刚刚添加得那行代码删除
然后重启mysql
[root@VM_167_102_centos /]# service mysqld restart Redirecting to /bin/systemctl restart mysqld.service [root@VM_167_102_centos /]#
然后就可以使用刚才设置得密码进入mysql了
[root@VM_167_102_centos /]# mysql -uroot -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 3 Server version: 5.7.17 Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement. mysql>
设置开机自动重启
[root@VM_167_102_centos /]# systemctl enable mysqld
[root@VM_167_102_centos /]# systemctl daemon-reload
为了确保远程能访问还得增加3306端口开放
这样centos7_64位安装mysql5.7.17就搞定啦。
不对得地方请各位大佬指正
在centos 7下安装mysql 5.7.17
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。