很纠结,ecs安装mysql找了很久没找到一个相对比较合适的 执行顺序,以下为我自己按照步骤一步一步在阿里云机器上执行的命令。
linux:命令如下
1,wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm ,此处如果不行,浏览器中放入 “http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm” 地址直接下载,然后上传的ecs就行了。
2,yum module disable mysql , 解决 “Error: Unable to find a match”
3,安装源:yum localinstall mysql57-community-release-el7-8.noarch.rpm
4,检查MySQL源安装情况: yum repolist enabled | grep “mysql.-community.”
5,安装mysql服务:yum install mysql-community-server
6,启动MySQL: systemctl start mysqld
7,设置开机启动MySQL:systemctl enable mysqld
8,设置开机启动MySQL:systemctl daemon-reload
9,查找并修改MySQL默认密码:grep ‘temporary password’ /var/log/mysqld.log
10,登录mysql:mysql -uroot -p 输入第9步的密码登录
11,在mysql控制台 修改密码: alter userroot@localhost identified by ‘你的新密码’;
12,在mysql控制台 设置远程连接:GRANT ALL PRIVILEGES ON . TO ‘用户’@’%’ IDENTIFIED BY ‘密码’ WITH GRANT OPTION;
13,在mysql控制台 刷新权限: flush privileges;
14,退出mysql控制台:exit
15,修改mysql配置:vi vi /etc/my.cnf 按键盘i之后,添加
lower_case_table_names=1 # 这个是大小写不敏感
sql-mode=“NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION” # 解决 group by的mysql问题 (具体参考:https://blog.csdn.net/weixin_43375482/article/details/97810775)
然后 “:wq” 保存后退出编辑
16,重启mysql: systemctl restart mysqld
17,查看mysql状态:systemctl status mysqld