centos7 install mysql5.7

2019-03-11  本文已影响0人  全都是泡沫啦

记录centos7中安装mysql5.7(测试成功)

查看当前rpm mysql源
rpm -qa | grep mysql
    mysql-community-libs-compat-5.7.25-1.el7.x86_64
    mysql-community-common-5.7.25-1.el7.x86_64
    mysql-community-libs-5.7.25-1.el7.x86_64
移除rpm mysql源
yum remove mysql-community-libs-5.7.25-1.el7.x86_64

获取最新mysql rpm
wget https://repo.mysql.com/get/mysql80-community-release-el7-2.noarch.rpm

安装rpm源
yum localinstall  mysql80-community-release-el7-2.noarch.rpm 

检查mysql源是否安装成功:yum repolist enabled | grep "mysql.*-community.*"
改变默认安装的mysql版本:vim /etc/yum.repos.d/mysql-community.repo   (enabled=1)我这里安装为5.7

yum install mysql-community-server

mysqld --initialize 注意在日志/var/log/mysqld.log 中存在初始化密码A temporary password is generated for root@localhost: h>iHgVkj&78;

启动:systemctl start mysqld 
    出现如下报错mysqld: Table 'mysql.plugin' doesn't exist:解决方式 删除datadir中内容执行mysqld --initialize
    [ERROR] InnoDB: The innodb_system data file 'ibdata1' must be writable   datadir木有权限:chmod -R 777 /var/lib/mysql/

设置开机启动
systemctl enable mysqld
systemctl daemon-reload

mysql -uroot -p (密码为cat /var/log/mysqld.log |grep 'temporary password' )
重置密码:set password for 'root'@'localhost'=password('Paul123');

修改默认字符
vi /etc/my.cnf 末尾追加:

[client]
default-character-set = utf8mb4
[mysql]
default-character-set = utf8mb4
[mysqld]
character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci

systemctl restart mysqld 
show variables like '%character%';
show variables like 'collation%';


sql_log_bin与log-bin根据自己情况进行开启

允许远程连接
use mysql
update user set host = ’%’ where user = ’root’ ;
flush privileges

对于字符集的设置:建议都使用utf8mb4,以下是修改方案
https://mathiasbynens.be/notes/mysql-utf8mb4#utf8-to-utf8mb4

上一篇下一篇

猜你喜欢

热点阅读