个人笔记,用于记录
# 安装 sudo apt-get install mysql-server # 初始化配置 sudo mysql_secure_installation
service mysql status
service mysql start/restart
service mysql stop
netstat -an|grep 3306 vim /etc/mysql/mysql.conf.d/mysqld.cnf
update user set plugin='mysql_native_password' where user='root'; flush privileges;
update user set authentication_string=password('root') where user='root'; flush privileges;
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;
# 解决方式 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