经过多番波折,终于理清楚,现在写下本篇文章。
系统为:Ubuntu 12.04 64位
(1)安装server
apt-get install mysql-server
安装后默认开启了server
(2) 安装client
apt-get install mysql-client
安装完毕后,利用WinSCP远程文件管理工具可以在/etc/目录下查看到Mysql文件夹(3) 上面的顺利后,接下来是更改数据库root的密码
返回根目录:mysqladmin -u root password 'passw0rd'
(4) 完成后,接下来就是修改远程访问权限
在/etc/mysql/my.cnf文件(或用locate my.cnf搜索该文件位置)中注释掉bind-address 127.0.0.1(禁止远程访问,只允许本地访问);
进入mysql:mysql -uroot -ppassw0rd
在mysql中使用:
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'IDENTIFIED BY 'passw0rd' WITH GRANT OPTION; FLUSH PRIVILEGES;
目的是在改mysql-server上允许任何的机器(%)以用户名(root)及密码(passw0rd)来连接到该serve上;
再在mysq中,输入:
mysqll>use mysql;
mysql>select host,user from user;
应该会出现类似以下的结果:
+-----------+------------------+
| host | user |
+-----------+------------------+
| % | root |
| 127.0.0.1 | root |
| c2-1 | root |
| localhost | debian-sys-maint |
| localhost | root |
+-----------+------------------+
%表明了已经授权给了远程访问的任何机器。
最后重启mysql,尝试下是否可以成功的远程连接。
mysql的操作方法如下:
启动:sudo /etc/init.d/mysql start
停止:sudo /etc/init.d/mysql stop
重启:sudo /etc/init.d/mysql restart