CentOS7设置MySQL

甘当你,忠于自己,活得像自己。

清单:
Name Version
CentOS 7
MySQL 5.7
  1. 反省是不是业已设置MySQL
    rpm -qa | grep mysql
  2. 下载MySQL源安装包
    # wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
  3. 安装MySQL源
    # yum localinstall mysql57-community-release-el7-8.noarch.rpm
  4. 自我批评MySQL源是否安装成功
    # yum repolist enabled | grep "mysql.*-community.*"

    yum资源列表

  5. 安装MySQL
    # yum install mysql-community-server

  6. 启动MySQL服务
    # systemctl start mysqld
  7. 设置开机启动(如无欲而超了)

# systemctl enable mysqld
# systemctl daemon-reload
  1. 赢得MySQL默认密码
    # grep 'temporary password' /var/log/mysqld.log

    MySQL默认密码

  2. 修改密码(需蕴涵大小写英文、数字、特殊字符且超过8各项)

# mysql -u root -p
# set password for 'root'@'localhost'=password('MySQL@lipuan.2018');
  1. 部署默认编码utf8,文件/etc/my.cnf中[mysqld]下加入

character_set_server=utf8
init_connect='SET NAMES utf8'
  1. 要害目录
    布局文件: /etc/my.cnf
    日记文件: /var/log//var/log/mysqld.log
    劳启动脚本: /usr/lib/systemd/system/mysqld.service
    socket文件: /var/run/mysqld/mysqld.pid

  2. 忘却密码操作,文件/etc/my.cnf中[mysqld]下加入
    skip-grant-tables
    重启MySQL
    # service mysqld restart
    改变到步骤9修改密码,成功后去除文件/etc/my.cnf中的skip-grant-tables

网站地图xml地图