Linux安装mysql并允许远程访问

1 安装mysql

sudo apt-get update

sudo apt-get install mysql-server mysql-client

2 测试mysql是否安装

mysql -u root -p

3 创建一个远程连接的用户

GRANT ALL PRIVILEGES ON *.* TO 'test'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;

flush privileges;

SELECT DISTINCT CONCAT('User:''',user,'''@''',host,''';') AS query FROM mysql.user;

4 退出数据库,用vim打开

vim /etc/mysql/mysql.conf.d/mysqld.cnf

注释掉 bind-address = 127.0.0.1

5 重启数据库

/etc/init.d/mysql restart

你可能感兴趣的:(Linux安装mysql并允许远程访问)