CentOS7;Mysql5.7
安装# 获取依赖 wget https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm # 安装依赖 yum -y localinstall mysql57-community-release-el7-11.noarch.rpm # 在线安装mysql yum -y install mysql-community-server # 设置开机启动 systemctl enable mysqld systemctl daemon-reload修改初始密码
mysql安装完成之后,会在/var/log/mysqld.log文件中给root生成了一个临时的默认密码。
获取这个初始密码: vim /var/log/mysqld.log
修改密码:
mysql -u root -p #输入刚刚获取的密码 ALTER USER 'root'@'localhost' IDENTIFIED BY '123456'; # 进入mysql命令行后,修改密码 GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION; # 设置远程登录设置mysql默认编码
打开配置文件:vim /etc/my.cnf`
添加内容:
character_set_server=utf8 init_connect='SET NAMES utf8'
重启:systemctl restart mysqld