CentOS安装MySQL

  1. 下载并安装MySQL的yum repository

    wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm

  2. yum安装MySQL

    yum -y install mysql57-community-release-el7-10.noarch.rpm

  3. 安装MySQL服务器

    yum -y install mysql-community-server

  4. 启动MySQL

    systemctl start mysqld.service

  5. 查看MySQL运行状态

    systemctl status mysqld.service

  6. 获取MySQL默认密码

    grep ‘password’ /var/log/mysqld.log

  7. 进入数据库

    mysql -u root -p

  8. 修改密码

    alter user ‘root’@’localhost’ identified by ‘密码’

  9. 修改MySQL语言

    exit

    vim /etc/my.cnf

    添加4行内容

    在最上面添加两行

    [client] default-character-set=utf9

    在[mysqld]中添加两行

    character-set-server=utf8 collation-server=utf8_general_ci

  10. 重启mysqld.service并查看运行状态

systemctl restart mysqld.service

systemctl status mysqld.service
  1. 进入MySQL并查看MySQL语言
mysql -u root -p

status

Server characterset: utf8 Db characterset: utf8 Client characterset: utf8 Conn. characterset: utf8
  1. 开放3306端口
firewall-cmd --zone=public --add-port=3306/tcp --permanent
  1. 重启防火墙
systemctl restart firewalld.service

文章来源于互联网,如有雷同请联系站长删除:CentOS7安装MySQL

发表评论