这里有新鲜出炉的 Mysql 教程,程序狗速度看过来!
MySQL 是一个开放源码的小型关联式数据库管理系统,开发者为瑞典 MySQL AB 公司。MySQL 被广泛地应用在 Internet 上的中小型网站中。由于其体积小、速度快、总体拥有成本低,尤其是开放源码这一特点,许多中小型网站为了降低网站总体拥有成本而选择了 MySQL 作为网站数据库。
这篇文章主要介绍了使用 YUM 在 Linux(CentOS 7) 下安装 mysql 5.7.18 的教程详解, 非常不错,具有参考借鉴价值,需要的朋友可以参考下
项目需要使用 MySQL,由于以前都是在 windows 下傻瓜式安装,基本没有遇到什么问题,但是这次是在服务器上安装,由于到 Linux 上安装软件不熟悉,走了不少弯路,耽误了好多时间。总结下来,以免下次再走弯路。
**************************** 图片插入不成功,不知道是怎么回事 *********************************
一、各种环境:
linux 版本:CentOS Linux release 7.2.1511 (core)
mysql 版本:community sercer 5.7.18
使用的 yum 安装包:
- Red Hat Enterprise Linux 7 / Oracle Linux 7 (Architecture Independent), RPM Package 25.1K
- Download
- (mysql57-community-release-el7-11.noarch.rpm)
二 :安装步骤
我是先在 windows 上下载安装包,然后通过 xshell 导入到服务器中。然后根据 mysql 官网上的步骤安装的。任何教程都没有官网上的靠谱,之前在网上搜了好多教程,每个教程的安装方法都不一样,搞得我很郁闷,而且,都没有成功。最后还是通过官网上的教程安装成功。
2.1 选择安装指南
2.2 点进入之后选择通用二进制版本。 installing MySQL on Unix/Linux Using Generic Binaries
2.3 按照上面的操作一步一步执行就可以了。
- shell> yum search libaio # search for info(Mysql安装需要以来libaio库,所以需要先安装libaio库)
- shell> yum install libaio # install library
- shell> groupadd mysql
- shell> useradd -r -g mysql -s /bin/false mysql
- shell> cd /usr/local
- shell> tar zxvf /path/to/mysql-VERSION-OS.tar.gz
- shell> ln -s full-path-to-mysql-VERSION-OS mysql
- shell> cd mysql
- shell> mkdir mysql-files
- shell> chmod 750 mysql-files
- shell> chown -R mysql .
- shell> chgrp -R mysql .
- shell> bin/mysql_install_db --user=mysql # MySQL 5.7.5 (mysql5.7.5选择使用这个命令,如果你的mysql是5.7.6及以上,不需要执行这个命令)
- shell> bin/mysqld --initialize --user=mysql # MySQL 5.7.6 and up
- shell> bin/mysql_ssl_rsa_setup # MySQL 5.7.6 and up
- shell> chown -R root .
- shell> chown -R mysql data mysql-files
- shell> bin/mysqld_safe --user=mysql &
- # Next command is optional
- shell> cp support-files/mysql.server /etc/init.d/mysql.server
执行完以上所有步骤,安装就结束了。
2.4 安装结束后,启动 mysql 服务
- [root@***** /]# cd ~ #这里有一个问题,不知道需要需要切换到 "~"目录,之前没有"~",启动不成功,不确定是我sytemctl start mysqld.service命令输入错了还是别的原因。
- [root@***** ~]# sytemctl start mysqld.service
查看是否启动成功
- [root@***** ~]# sytemctl status mysqld.service
如果有这个标识则启动成功
2.5 获取安装时的临时密码,用以登录 mysql
- grep'temporary
- password'/var/log/mysqld.log
- 2017-05-10T00:55:46.982233Z
- 1 [Note] A temporary password is generated for root@localhost: 5C::+lMjqi+z
红框中的是临时密码。
2.5 使用临时密码登录
- [root@****** ~]# 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.18
2.6 更改密码
- mysql > ALTER USER 'root'@'localhost'IDENTIFIED BY 'newpassword';
- Query OK,
- 0 rows affected(0.00 sec)
注意:最新的 mysql 对安全性有很高的要求,密码必须包含特殊字符、大小写、数字,否则更改不成功,报错。
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
以上所述是小编给大家介绍的使用 YUM 在 Linux(CentOS 7) 下安装 mysql 5.7.18 的教程详解,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 PHPERZ 网站的支持!
来源: http://www.phperz.com/article/17/0529/335187.html