centos7安装mysql

网上有更好的教程:

 下载并安装MySQL官方的 Yum Repository

[root@localhost ~]# wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm

 

  使用上面的命令就直接下载了安装用的Yum Repository,大概25KB的样子,然后就可以直接yum安装了。

[root@localhost ~]# yum -y install mysql57-community-release-el7-10.noarch.rpm

 

之后就开始安装MySQL服务器。

[root@localhost ~]# yum -y install mysql-community-server



这步可能会花些时间,安装完成后就会覆盖掉之前的mariadb。 

如果遇到安装不成功,提示:The GPG keys listed for the “MySQL 5.7 Community Server” repository are already installed but they are not correct for this package.

Check that the correct key URLs are configured for this repository.

给yum添加–nogpgcheck来强制安装,如下命令即可

yum install mysql-server --nogpgcheck


2.若报错:

file /usr/share/mysql/czech/errmsg.sys from install of mysql-community-common-5.7.44-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.68-1.el7.x86_64
file /usr/share/mysql/danish/errmsg.sys from install of mysql-community-common-5.7.44-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.68-1.el7.x86_64
file /usr/share/mysql/dutch/errmsg.sys from install of mysql-community-common-5.7.44-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.68-1.el7.x86_64
file /usr/share/mysql/english/errmsg.sys from install of mysql-community-common-5.7.44-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.68-1.el7.x86_64
file /usr/share/mysql/estonian/errmsg.sys from install of mysql-community-common-5.7.44-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.68-1.el7.x86_64

则:

rpm -qa | grep mariadb
rpm -e --nodeps mariadb-libs-5.5.60-1.el7_5.x86_64//删除成功

同样mysql-client也用这个方法:

wget -i -c http://dev.mysql.com/get/mysql-community-client-5.7.39-1.el7.x86_64.rpm
yum -y install mysql-community-client-5.7.39-1.el7.x86_64.rpm
yum install mysql-community-client --nogpgcheck


https://dev.mysql.com/downloads/mysql/5.7.html,下面这段留记念,解决问题请忽略:

选择Red Hat Enterprise Linux / Oracle Linux
下载:
mysql-community-client-5.7.33-1.el7.x86_64.rpm
mysql-community-common-5.7.33-1.el7.x86_64.rpm
mysql-community-libs-5.7.33-1.el7.x86_64.rpm
mysql-community-libs-compat-5.7.33-1.el7.x86_64.rpm
mysql-community-server-5.7.33-1.el7.x86_64.rpm
我没有用(mysql-5.7.33-1.el7.x86_64.rpm-bundle.tar)


上传到centos7
yum -y install numactl
rpm -ivh mysql-community-client-5.7.33-1.el7.x86_64.rpm
rpm -ivh mysql-community-common-5.7.33-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.33-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-compat-5.7.33-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-5.7.33-1.el7.x86_64.rpm




已经有了4个安装文件,安装步骤如下:

rpm -qa | grep mariadb
#下面的包名根据上面查出来的定
rpm -e --nodeps mariadb-libs-5.5.68-1.el7.x86_64
rpm -ivh mysql-community-common-5.7.44-1.el7.x86_64.rpm 
rpm -ivh mysql-community-libs-5.7.44-1.el7.x86_64.rpm 
yum -y install libaio
rpm -ivh mysql-community-server-5.7.44-1.el7.x86_64.rpm


启动配置mysql

vi  /etc/my.cnf
在[mysqld]下添加:
skip-grant-tables=1

service mysqld restart

mysql -u root -p

use mysql;

update user set host='%' where host='localhost';

update user set authentication_string = password('xxx'), password_expired = 'N', password_last_changed = now() where user = 'root';

quit;

再把上面的skip-grant-tables=1去掉,这样就可以密码登录了。


mysql5.7默认分组字段必须在查询字段里,修改这个配置:
mysql命令行,执行命令    
select @@sql_mode;
这样就可以查出sql_mode的值,复制这个值,在my.cnf中添加配置项(把查询到的值删掉only_full_group_by这个选项,其他的都复制过去):
sql_mode=STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION;    

再加两行,

character-set-server=utf8

bind-address=0.0.0.0

关闭防火墙:

systemctl stop firewalld

文/程忠 浏览次数:0次   2021-02-22 11:59:36

相关阅读


评论:
点击刷新

↓ 广告开始-头部带绿为生活 ↓
↑ 广告结束-尾部支持多点击 ↑