前言
个人笔记,用于记录
MySQL
安装
# 安装
sudo apt-get install mysql-server
# 初始化配置
sudo mysql_secure_installation
服务启动关闭状态
- 状态
service mysql status
- 启动/重启
service mysql start/restart
- 关闭
service mysql stop
修改配置
- 连接,输入MySQL
- 端口
netstat -an|grep 3306
vim /etc/mysql/mysql.conf.d/mysqld.cnf
- plugin
update user set plugin='mysql_native_password' where user='root';
flush privileges;
- authentication_string
update user set authentication_string=password('root') where user='root';
flush privileges;
- 查看root用户的访问IP
user mysql;
select user,host from user where user='root';
6. 将其修改为任意IP可以访问,%
use mysql;
update user set host='%' where user='root' and host='localhost';
7. 下面是授予权限,如果出现其他主机无法连接的情况
grant all privileges on *.* to root@'%' identified by 'root' with grant option;quit
flush privileges;
8.0.x mysql 版本
- 问题full_group_by
# 解决方式
cd /etc/mysql/mysql.conf.d
vim mysqld.cnf
在文件的【mysqld】下面加上一行,或者去掉已有的sql_mode=only_full_group_by
改为
sql_mode=
STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION