下载Linux版mysql,Linux操作
下载MySql安装包:wget https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
提示wget命令不存在:yum -y install wget
安装mysql安装源:yum -y localinstall mysql57-community-release-el7-11.noarch.rpm
线安装MySQL:yum -y install mysql-community-server
启动MySQL服务:systemctl start mysqld
设置开机启动:
systemctl enable mysqld
systemctl daemon-reload
查看root登录密码:vim /var/log/mysqld.log 或者 grep 'temporary password' /var/log/mysqld.log
登录root:mysql -u root -p
修改密码:mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'GodH233593@'; //mysql5.7默认密码策略要求密码必须是大小写字母数字特殊字母的组合,至少8位
设置允许远程登录:mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'GodH233593@' WITH GRANT OPTION;
退出:mysql> exit
防火墙开放3306端口:
firewall-cmd --zone=public --add-port=3306/tcp --permanent
firewall-cmd --reload
配置mysql默认编码为utf-8
修改/etc/my.cnf配置文件,在[mysqld]下添加编码配置,如图
character_set_server=utf8mb4
重启MySQL:systemctl restart mysqld
登录root用户查看编码:mysql> show variables like '%character%'