MySQL 安装笔记

增加 MySQL YUM 仓库

  1. 去 MySQL YUM 仓库的下载页面 (http://dev.mysql.com/downloads/repo/yum/ 下载对应操作系统的安装文件
  2. rpm -ivh mysql57-community-release-el5-8.noarch.rpm
  3. yum repolist enabled | grep "mysql.-community."

选择一个发行版本

  1. yum repolist all | grep mysql
  2. yum repolist enabled | grep mysql

安装 MySQL

yum install mysql-community-server

启动 MySQL 服务

sudo service mysqld start
sudo service mysqld status

服务在初始化启动成功之后,一个管理的用户'root'@'localhost将会被创建,默认的密码保存在错误的日志中,通过以下方式去查找初始密码

sudo grep 'temporary password' /var/log/mysqld.log
2018-01-29T03:14:08.492127Z 1 [Note] A temporary password is generated for root@localhost: dnw3rVeQp+L:

修改密码

mysql -uroot -p
ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';