«

RedHat6.5/CentOS6.5安装Mysql5.7.20的教程详解

时间:2024-3-2 01:31     作者:韩俊     分类: Mysql


下载rpm安装包

Mysql官网:https://dev.mysql.com/downloads/mysql/

选择版本下载:

可以使用wget命令下载:

[root@localhost opt]#wget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.20-1.el6.x86_64.rpm-bundle.tar

注意RedHat的版本和系统位数。

查看依赖的库

[root@localhost opt]# yum search libaio
[root@localhost opt]# yum install libaio

查看系统之前是否有安装过mysql相关版本

[root@localhost opt]# rpm -qa | grep mysql
[root@localhost opt]# rpm -qa | grep mariadb

有则删除,有几个删除几个

[root@localhost opt]# rpm -e mariadb-libs-5.5.44-2.el7.x86_64 --nodeps

安装

按照顺序安装软件包

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

创建mysql用户和用户组

[root@localhost /]# groupadd mysql
[root@localhost /]# useradd -r -g mysql -s /bin/false mysql

创建mysql数据存放目录

[root@localhost /]# mkdir -p /data/mysql
[root@localhost /]# chown mysql.mysql /data/mysql
[root@localhost /]# ll -d /data/mysql/
drwxr-xr-x. 2 mysql mysql 6 9月 17 17:37 /data/mysql/

修改/etc/my.cnf配置文件

[mysqld]
init-connect='SET NAMES utf8mb4'
default-storage-engine=INNODB
character-set-server=utf8mb4
datadir=/data/mysql
socket=/var/lib/mysql/mysql.sock
assorted security risks
symbolic-links=0
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
validate_password=off
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
lower_case_table_names=1
[mysql]
default-character-set = utf8mb4
[client]
default-character-set = utf8mb4

初始化mysql

[root@localhost /]# /usr/sbin/mysqld --initialize --user=mysql

查看初始化密码

[root@localhost /]# grep "root@localhost" /var/log/mysqld.log

登录mysql并修改密码

mysql> set password = password('123456');

允许远程访问(不推荐)

mysql> use mysql; 
mysql> select host,user,password from user; 
mysql> update user set password=password('xxxxxx') where user='root'; 
mysql> update user set host='%' where user='root' and host='localhost'; 
mysql> flush privileges;

总结

以上所述是小编给大家介绍的RedHat6.5/CentOS6.5安装Mysql5.7.20的教程详解,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对毛票票网站的支持!

标签: linux

热门推荐