首页 > 技术文章 > yum安装MySQL5.7

zhangshengdong 原文

yum安装MySQL5.7

有的时候,开发测试环境没有高性能的要求。因此,配置MySQL版本的时候。简单配置,也需即可达到目的。

1.卸载MySQL(原有的)

[root@localhost ~]# rpm -qa |grep mysql
mysql-libs-5.1.73-7.el6.x86_64
[root@localhost ~]# rpm -e mysql-libs
error: Failed dependencies:
	libmysqlclient.so.16()(64bit) is needed by (installed) postfix-2:2.6.6-6.el6_7.1.x86_64
	libmysqlclient.so.16(libmysqlclient_16)(64bit) is needed by (installed) postfix-2:2.6.6-6.el6_7.1.x86_64
	mysql-libs is needed by (installed) postfix-2:2.6.6-6.el6_7.1.x86_64
[root@localhost ~]# rpm -e --nodeps mysql-libs
[root@localhost ~]# rpm -qa |grep mysql

2.MySQL5.7的基础包

[root@youxi2 ~]# yum -y install make gcc-c++ cmake bison-devel ncurses-devel libaio libaio-devel net-tools  //安装依赖包
[root@localhost opt]# yum -y install numactl

3.下载&安装MySQL5.7 for CentOS 6

[root@localhost ~]# cat /etc/issue
CentOS release 6.8 (Final)
Kernel 
 on an m

开始安装MySQL5.7

[root@localhost opt]# rpm -ivh mysql-community-common-5.7.30-1.el6.x86_64.rpm 
[root@localhost opt]# rpm -ivh mysql-community-libs-5.7.30-1.el6.x86_64.rpm 
[root@localhost opt]# rpm -ivh mysql-community-client-5.7.30-1.el6.x86_64.rpm
[root@localhost opt]# rpm -ivh mysql-community-server-5.7.30-1.el6.x86_64.rpm
[root@localhost opt]# rpm -ivh mysql-community-devel-5.7.30-1.el6.x86_64.rpm

4.创建MySQL数据库的数据目录

mkdir -p /opt/mysql/data
chown -R mysql:mysql /opt/mysql/data/
修改配置文件
[root@localhost lib]# cat /etc/my.cnf
###修改数据目录位置
datadir=/opt/mysql/data

5.初始化MySQL数据库

[root@localhost lib]# service mysqld start
初始化 MySQL 数据库:                                      [确定]
正在启动 mysqld:                                          [确定]
[root@localhost lib]# service mysqld status
mysqld (pid  20017) 正在运行...

6.使用临时生成的MySQL密码登录

[root@localhost lib]# mysql -uroot -p'f36LZ>f)Wkgb'
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 4
Server version: 5.7.30

Copyright (c) 2000, 2020, 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>

7.修改MySQL的密码策略

mysql> set password for root@localhost=password('Mysqlxxxxxxx');

推荐阅读