环境:centos7.4
mysql:5.7
安装方式yum安装:
wget https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm
rpm -ivh mysql57-community-release-el7-9.noarch.rpm
yum install mysql-server
systemctl start mysqld
grep 'temporary password' /var/log/mysqld.log
mysql -uroot -p
修改配置文件:
character_set_server=utf8
init_connect='SET NAMES utf8'
validate_password = off
修改密码:
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewP';
或者
mysql> set password for 'root'@'localhost'=password('MyNewP');
赋权:
添加远程登录用户
默认只允许root帐户在本地登录,如果要在其它机器上连接mysql,必须修改root允许远程连接,或者添加一个允许远程连接的帐户,为了安全起见,我添加一个新的帐户:
mysql> GRANT ALL PRIVILEGES ON *.* TO 'zhouyuqiang'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
参考文档:
https://www.linuxidc.com/Linux/2016-09/135288.htm