安装
添加安装源
rpm -Uvh https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
安装
yum install mysql-community-server
设置
防火墙设置
firewall-cmd --zone=public --permanent --add-service=mysqlfirewall-cmd --reload
开机自启动
systemctl enable mysqld
启动
systemctl start mysqld
查看root默认密码
grep 'temporary password' /var/log/mysqld.log
设置root新密码,新密码要求是大小写字母+数字+字符的组合。
//运行安全设置向导mysql_secure_installation//输入root默认密码Enter password for user root: ***//是否更改root密码Change the password for root ? ((Press y|Y for Yes, any other key for No) :y//设置新密码New password:***Re-enter new password: ***//是否删除匿名用户Remove anonymous users? (Press y|Y for Yes, any other key for No) : y//禁止root远程登录Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y//删除test数据库Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y//重新加载权限表Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
为安全root仅限本地登录,根据需要可以新建一个有管理员权限的远程用户
mysql -uroot -pGRANT ALL PRIVILEGES ON *.* TO '用户名'@'%' IDENTIFIED BY '登录密码' WITH GRANT OPTION;FLUSH PRIVILEGES;exit;