CentOS在线安装MySql5.7,并配置远程访问

in Linux with 0 comment

1 安装命令

wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
yum localinstall mysql57-community-release-el7-8.noarch.rpm
yum repolist enabled | grep "mysql.*-community.*"
yum install mysql-community-server
systemctl start mysqld
systemctl enable mysqld
systemctl daemon-reloa`

2 修改root密码

cat /var/log/mysqld.log
cat /var/log/mysqld.log | grep temporar`

修改mysql初始密码

mysql -u root –p
#输入 找到的 初始密码
#修改初始密码
set password for 'root'@'localhost'=password('pass1234');
#如果提示不让修改密码, 是因为密码强度不符合默认的密码策略
#首先,修改validate_password_policy参数的值
set global validate_password_policy=0;
#再修改密码的长度
set global validate_password_length=1;
#再次执行修改密码就可以了
set password for 'root'@'localhost'=password('pass1234')`

3 允许其他主机远程登录

#授权其他机器登陆
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'pass1234' WITH GRANT OPTION;FLUSH PRIVILEGES;
#允许指定主机远程访问
set global validate_password_policy=0;
GRANT ALL PRIVILEGES ON aossdb.* TO 'root'@'192.168.0.1' IDENTIFIED BY 'pass1234' WITH GRANT OPTION;

4 mysql控制台远程登录

    mysql -h {IP} {端口} -u {用户名} -p{密码}