阿里云CentOS服务器mysql安装
1.下载mysql源安装包(cd /usr/local/mysql)
# wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
2.安装mysql源(结尾出现 complete!则安装成功)
# yum localinstall mysql57-community-release-el7-8.noarch.rpm
3.检测是否安装完成
# yum repolist enabled | grep "mysql.*-community.*"
4.安装mysql(结尾出现 complete!则安装成功)
# yum install mysql-community-server
5.设置开启启动mysql服务
# systemctl enable mysqld
6.查看mysql版本
# rpm -aq | grep -i mysql
7.启动mysql
# systemctl restart mysqld
8.获取mysql初始密码
# grep 'A temporary password' /var/log/mysqld.log
9.修改mysql密码(必须含有数字,小写或大写字母,特殊字符)
# mysqladmin -u root -p'旧密码' password '新密码'
关闭mysql密码强度验证(validate_password)
(1). 编辑配置文件
# vim /etc/my.cnf ( 增加 validate_password=off)
(2).重启mysql
# systemctl restart mysqld
10.设置mysql远程访问
(1).登录mysql
# mysql -uroot -p'密码'
(2).授权一个用户访问权限(/可将ip改为%%,表示开启所有的)
grant all privileges on *.* to '用户名'@'ip' identified by '密码' with grant option;
11.配置阿里云安全组(开启3306端口。授权对象选择0.0.0.0/0所有ip可访问)
12.重启服务器