centos7安装配置mysql5.7

一 安装yum源

1 wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
2 yum localinstall mysql57-community-release-el7-8.noarch.rpm

检查yum源:

1 yum repolist enabled | grep "mysql.*-community.*"

结果显示如下三行,表示成功:

1 mysql-connectors-community/x86_64       MySQL Connectors Community           42
2 mysql-tools-community/x86_64            MySQL Tools Community                51
3 mysql57-community/x86_64                MySQL 5.7 Community Server          207

 

二 安装mysql

1 yum install mysql-community-server

 

三 启动mysql

1 systemctl start mysqld

 

四 查看mysql状态

1 systemctl status mysqld

显示如下,表示成功:

复制代码
 1 ● mysqld.service - MySQL Server
 2    Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
 3    Active: active (running) since Sat 2017-09-16 16:18:34 CST; 25s ago
 4      Docs: man:mysqld(8)
 5            http://dev.mysql.com/doc/refman/en/using-systemd.html
 6   Process: 5692 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=0/SUCCESS)
 7   Process: 5594 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
 8  Main PID: 5694 (mysqld)
 9    CGroup: /system.slice/mysqld.service
10            └─5694 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid
11 
12 Sep 16 16:18:29 centos7-10.211.55.5.shared systemd[1]: Starting MySQL Server...
13 Sep 16 16:18:34 centos7-10.211.55.5.shared systemd[1]: Started MySQL Server.
复制代码

 

五 设置开机启动

1 systemctl enable mysqld
2 systemctl daemon-reload

 

六 密码修改

先查看root的密码:

1 grep 'temporary password' /var/log/mysqld.log

显示密码如下:RK5&C(pW*AG(

1 2017-09-16T08:18:31.881461Z 1 [Note] A temporary password is generated for root@localhost: RK5&C(pW*AG(

登陆:

1 mysql -uroot -p

然后输入上边的密码进行登录,之后修改密码

1 ALTER USER 'root'@'localhost' IDENTIFIED BY 'Zhaojigang123!';

 

七 配置编码

1 vi /etc/my.cnf
2 添加如下内容:
3 character_set_server=utf8
4 init_connect='SET NAMES utf8'

 

八 重启mysql

1 systemctl restart mysqld

 

九 使用mysql客户端进行连接

客户端可以使用navicat或者AquaDataStudio18。

注意:如果mysql部署在远程机器上,此时首先需要关闭远程机器的防火墙,其次需要创建一个用户授予远程访问权限(因为mysql只允许root用户在本机访问)

1 关闭防火墙:centos7关闭防火墙

创建一个用户授予远程访问权限:通过root账号登陆mysql,之后执行:

1 GRANT ALL PRIVILEGES ON *.* TO 'zhaojigang'@'%' IDENTIFIED BY 'Zhaojigang123!' WITH GRANT OPTION;

你可能感兴趣的:(Linux,Tomcat)