1.准备工作
在MySQL官网中下载YUM源rpm安装包:https://dev.mysql.com/downloads/repo/yum/
更新yum源:
yum clean all
yum makecache
2.安装
yum localinstall mysql80-community-release-el7-1.noarch.rpm
安装mysql 命令:
yum install mysql-community-server
注意:如果报错信息:未找到匹配的参数: mysql-community-server 错误:没有任何匹配
yum module disable mysql
开启mysql服务:
systemctl start mysqld.service
设置开机自启:
systemctl enable mysqld.service
数据库的服务操作:
#启动mysql
systemctl start mysqld.service
#结束
systemctl stop mysqld.service
#重启
systemctl restart mysqld.service
#开机自启
systemctl enable mysqld.service
获取初始密码登录mysql
mysql在安装后会创建一个root@locahost账户,并且把初始的密码放到了/var/log/mysqld.log文件中;
cat /var/log/mysqld.log | grep password
3.设置
使用初始密码登录mysql
mysql -uroot -p
修改root的密码:
ALTER USER 'root'@'localhost' IDENTIFIED BY 'root';
远程设置:
mysql> use mysql;
mysql> update user set host='%' where user='root';
mysql> FLUSH PRIVILEGES;</pre>
如果配置忽略大小写
8.0配置忽略大小写需要在初始化之前
1.停止数据库服务后,修改vi /etc/my.cnf,在[mysqld]下面添加 lower_case_table_names=1
2.做好备份,删除数据库数据
rm -rf /var/lib/mysql
3.重启数据库
service mysql start
- 从上面的步骤日志获取密码,重新配置一遍就可以了
5.处理only_full_group_by
set sql_mode = 'STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';
set global sql_mode = 'STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';
set @@session.sql_mode = 'STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';
set @@Global.sql_mode = 'STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';