首页 > 代码库 > centos安装mysql57

centos安装mysql57

下载源安装文件

wget http://repo.mysql.com//mysql57-community-release-el7-8.noarch.rpm

wget https://repo.mysql.com//mysql57-community-release-el7-11.noarch.rpm


本地安装rpm包(配置MySQL安装源)

yum -y localinstall mysql57-community-release-el7-11.noarch.rpm


查看所有MySQL安装源(默认MySQL安装版本5.7)

yum repolist all | grep mysql


关闭MySQL 5.6安装源

sudo yum-config-manager --disable mysql56-community


开启MySQL 5.7安装源

sudo yum-config-manager --enable mysql57-community
没有yum-config-manager命令可以安装yum install yum-utils.noarch工具 或者编辑/etc/yum.repos.d/mysql-community.repo文件enable项为1表示开启,为0表示关闭

VI命令修改python版本为2.7

vi /usr/libexec/urlgrabber-ext-down

yum -y install yum-utils

vi /bin/yum-config-manager

 

安装MySQL

yum -y install mysql-devel mysql-community-server


启动MySQL

systemctl start mysqld.service


安全配置MySQL

mysql_secure_installation

 

设置密码

use mysql;

update user set password=password(‘密码‘) where user=‘root‘;

flush privileges;

配置

 

mysql配置文件为/etc/my.cnf

 

最后加上编码配置

 

[mysql]default-character-set =utf8

 

这里的字符编码必须和/usr/share/mysql/charsets/Index.xml中一致。

 

技术分享

 

2、远程连接设置

 

把在所有数据库的所有表的所有权限赋值给位于所有IP地址的root用户。

 

mysql> grant all privileges on *.* to root@‘%‘identified by ‘password‘;

 

如果是新用户而不是root,则要先新建用户

 

mysql>create user ‘username‘@‘%‘ identified by ‘password‘;  

 

重启MYSQL

1、可以将mysqld放到/etc/init.d
用/etc/init.d/mysqld restart命令重启
(cp mysql-5.5.31/support-files/mysql.server /etc/init.d/mysqld)


2、或者用systemctl
systemctl restart mysql
或者
systemctl restart mariadb


3、service mysql restart
service mariadb restart

此时就可以进行远程连接了。

 

centos安装mysql57