- 安装YUM repo
由于centos的yum源中没有MySQL,需要到MySQL官网下载yum repo的配置文件
wget https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm
然后进行repo的安装
[root@wg001 ~]# rpm -ivh mysql57-community-release-el7-9.noarch.rpm
警告:mysql57-community-release-el7-9.noarch.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY
准备中... ################################# [100%]
正在升级/安装...
1:mysql57-community-release-el7-9 ################################# [100%]
[root@wg001 ~]#
# yum makecache
之后就可以用yum进行安装了
在安装之前需要把之前的MySQL删掉: 使用
rpm -qa |grep mysql
发现有输出结果,依次删除
rpm -e **** --nodeps
开始安装MySQL
#yum install mysql-community-server
安装时间有点长,在十分钟左右。
启动MySQL
[root@wg001 ~]# systemctl start mysqld
配置MySQL,获取MySQL的临时密码
[root@wg001 ~]# grep 'temporary password' /var/log/mysqld.log
2018-12-02T14:08:10.483897Z 1 [Note] A temporary password is generated for root@localhost: e%3t6nfd.vrK
登陆数据库
[root@wg001 ~]# mysql -uroot -pe%3t6nfd.vrK
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.24
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
可以看到版本号是5.7.24
登陆后需要及时修改密码
mysql> set password=password("ZMedu118118!");
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> grant all privileges on *.* to root@"%" identified by "ZMedu118118!";
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> flush privileges
注意: 密码不能设置的过于简单,如果太简单会报错。
设置安全选项
# mysql_secure_installation
默认配置文件
配置文件:/etc/my.cnf
日志文件:/var/log//var/log/mysqld.log
服务启动脚本:/usr/lib/systemd/system/mysqld.service
socket文件:/var/run/mysqld/mysqld.pid
本文链接:http://www.geekyunwei.com/1214.html
网友评论comments