远程访问mysql

用root登录mysql
mysql -u root -p
use mysql;
grant all privileges on . to username@"%" identified by 'password' with grant option;
exit;

sudo vi /etc/mysql/my.cnf
注释掉bind-address = 127.0.0.1
也有sudo vi /etc/mysql/mysql.conf.d/mysqld.cnf

sudo service mysql restart

搞定!

create user 'user'@'%' identified by '******';
create database db_name DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
grant all privileges on db_name.* to 'user'@'%' identified by '******';
flush privileges;
插入中文乱码,连接字符串+Charset=utf8;

标签: none

添加新评论