mysql 设置远程连接

机器用的debian 7.wheezy系统。其他系统就不写了。过程一样。centos与redhat 部分安装完程序命令部分为mysqld

source.list设置部分前面有说。就不说了。

sudo apitude mysql-server;sudo apitude mysql-client;


安装过程中会要求输入密码。输入root


安装完成以后。

修改配置文件,去掉绑定代码

vim /etc/mysql/my.conf

#bind_address = 127.0.0.1


下一步。连接本地mysql登录。

mysql -h localhost -u root -proot

注意这里-proot是 紧靠在一起的。root为密码。

不出意外会提示

mysql>命令行。说明登录成功。

新建1个用户.

create user watsy identified by 'hellomysql';

新建1个数据库

create database hellomysqldb;


设置用户访问权限

grant all privileges on *.* to watsy@'localhost' identified by 'hellomysql' with grant option; 
grant all privileges on `hellomysqldb`.* to watsy@'%' identified by 'hellomysql' with grant option;
flush privileges;

执行完以后退出mysql

exit

重启mysql数据库

sudo /etc/init.d/mysql restart

远程执行

mysql -h remoteip -u watsy -phellomysql

不出意外,可以登录了。


以上代码为记忆写岀。有问题欢迎留言。


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值