Linux CentOS 7.0在线安装MySQL 5.7版本

1、配置YUM源

在MySQL官网中下载YUM源rpm安装包:http://dev.mysql.com/downloads/repo/yum/

下载mysql源安装包 shell> wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm 安装mysql源 shell> yum localinstall mysql57-community-release-el7-8.noarch.rpm 检查mysql源是否安装成功 shell> yum repolist enabled | grep "mysql.-community." 可以修改vim /etc/yum.repos.d/mysql-community.repo源,改变默认安装的mysql版本。比如要安装5.6版本,将5.7源的enabled=1改成enabled=0。然后再将5.6源的enabled=0改成enabled=1即可

2、安装MySQL

shell> yum install mysql-community-server

3、启动MySQL服务

shell> systemctl start mysqld
查看MySQL的启动状态
shell> systemctl status mysqld
● mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; disabled; vendor preset: disabled)
Active: active (running) since 五 2016-06-24 04:37:37 CST; 35min ago
Main PID: 2888 (mysqld)
CGroup: /system.slice/mysqld.service
└─2888 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid
6月 24 04:37:36 localhost.localdomain systemd[1]: Starting MySQL Server...
6月 24 04:37:37 localhost.localdomain systemd[1]: Started MySQL Server.

4、开机启动

 shell> systemctl enable mysqld
shell> systemctl daemon-reload

5 运行MySQL

shell>  service mysqld start
获取初始密码
grep "password" /var/log/mysqld.log
#### 下面是返回的内容,密码也末尾
2018-09-30 T08:06:46.998346Z 1 [Note] A temporary password is generated for root@localhost: y3h2rpgryw.E
修改密码
使用临时密码登陆
mysql -u root -p
##由于 5.7 处于安全考虑,不让设置简单密码,要先更改其密码机制
set global validate_password_policy=LOW;

设置密码长度

set global validate_password_length=6;

修改密码

 SET PASSWORD = PASSWORD('111111');
ALTER USER 'root'@'localhost' PASSWORD EXPIRE NEVER;
flush privileges;
远程和本地访问
 use mysql;
 update user set host = '%' where user = 'root';

使配置生效

 flush privileges;
 设置字符集

登陆数据库后

 set character_set_database=utf8;
flush privileges;

原文地址:https://blog.csdn.net/qq_32168087/article/details/82910267

0评论