阿里云服务器上安装MYSQL5.7

1.下载yum源

wget https://repo.mysql.com//mysql57-community-release-el7-11.noarch.rpm

2.安装yum源

rpm -ivh mysql57-community-release-el7-11.noarch.rpm

3.安装mysql服务

yum install -y mysql-community-server

4.重启Mysql服务

systemctl restart  mysqld.service

5.设置开机启动

systemctl enable mysqld

6.查看mysql默认密码

cat /var/log/mysqld.log | grep root@localhost

[Note] A temporary password is generated for root@localhost: tffg2*d7q=;

7.如果没有.log文件中没有默认密码,则

修改/etc/my.cnf,在 [mysqld] 小节下添加一行:skip-grant-tables=1 (这一行配置让 mysqld 启动时不对密码进行验证)

保存并退出,重启服务

systemctl restart  mysqld.service

8.进入mysql命令框,

mysql

9.切换到MySql数据库

use mysql

#修改MySql密码(root@123是新密码)

(password_expired='N',  设置密码失效N应该是NO)

(password_last_changed=now()  设置修改密码的时间,为当前时间)

update

user set authentication_string = password('root@123'),

password_expired='N',

password_last_changed=now()

where

user='root';

10.退出

quit;

11.重启服务

systemctl restart  mysqld.service

12.登陆mysql(输入密码)

mysql -u root -p

13.切换到MySql数据库

use mysql

14.授权远程登陆

update user set host='%' where host='localhost';

quit;

systemctl restart  mysqld.service

15.设置mysql字符格式在/etc/my.cnf中添加下面(设置完之后重启服务)

[mysqld]

default-storage-engine=INNODB

character-set-server=utf8

collation-server=utf8_general_ci

你可能感兴趣的:(阿里云服务器上安装MYSQL5.7)