解决mysql只能使用localhost访问问题
mysql> use mysql;
mysql> select host,user form user;
mysql>update user set host = '%' where user ='root';
mysql>select host,user from user;
mysql> flush privileges;
mysql> quit;
sudo vim /etc/mysql/my.cnf
# The MySQL database server configuration file.
# You can copy this to one of:
# - "/etc/mysql/my.cnf" to set global options,
# - "~/.my.cnf" to set user-specific options.
#
# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use.
#
# For explanations see
#
# * IMPORTANT: Additional settings that can override those from this file!
# The files must end with '.cnf', otherwise they'll be ignored.
#
!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mysql.conf.d/
[mysqld]
bind-address = 0.0.0.0
- 修改mysql数据库中配置 配置为root在所有host可登陆,并使用flush privileges使配置生效
- 修改my.cnf,添加/修改 bind-address = 0.0.0.0
解决使用golang无法使用time.Time类型取出timestamp问题
在打开数据库时 添加?parseTime=true选项即可
解决数据库无法写入中文问题
建表时设置 utf8
1
2
|
CREATE TABLE IF NOT EXISTS xxx (info TEXT CHARSET utf8 DEFAULT NULL);`
|
timestamp类型比较大小问题
1
2
|
SELECT xxx FROM xxx WHERE unix_timestamp(time)>unix_timestamp('2018-03-21)
|
注意时间加引号