Archive for January, 2010

Ubuntu安装MySQL

好久没写日志了,前段时间,域名没有备案,封掉了。

Ubuntu安装MySQL很方便,直接运行

sudo apt-get install mysql-server

就可以了。

但如果要MySQL能够外部访问的话,要做下修改。
登录MySQL

mysql -u root -p

授予需要外部访问的IP或者用户的权限

GRANT ALL PRIVILEGES ON *.* TO shishuo@'%' IDENTIFIED BY "shishuopassword"; 

其中 *.* 表示 数据库.表,你可以写为 shishuo.*
如:

GRANT ALL PRIVILEGES ON shishuodatabase.* TO shishuo@'%' IDENTIFIED BY "shishuopassword"; 

这条语句的意思就是,shishuo这个用户可以在任何IP下,用 shishuopassword 密码,访问shishuodatabase数据库,并具有对shishuodatabase的所有权限。

然后

vi /etc/mysql/my.cnf

修改
bind-address = 127.0.0.1

#bind-address = 127.0.0.1

重启

/etc/init.d/mysql restart

这样外部也能访问了。