1,卸载mysql
sudo apt-get autoremove --purge mysql-server-5.0 sudo apt-get remove mysql-server sudo apt-get autoremove mysql-server sudo apt-get remove mysql-commo
清理残留数据
dpkg -l |grep ^rc|awk '{print $2}' |sudo xargs dpkg -P
2,安装mysql
sudo apt-get install mysql-server sudo apt-get install mysql-client
安装完成后检查mysql是否启动:
sudo netstat -tap | grep mysql
当您运行该命令时,您可以看到类似下面的行:
tcp 0 0 localhost.localdomain:mysql *:* LISTEN -
如果服务器不能正常运行,您可以通过下列命令启动它:
sudo /etc/init.d/mysql restart
进入mysql
$mysql -uroot -p 管理员密码
配置 MySQL 的管理员密码:
sudo mysqladmin -u root password newpassword
3,开启远程访问功能
mysql安装后,默认是不支持远程访问的。
- vi打开mysql配置文件:/etc/mysql/my.cnf,注释掉下面红色这一行:
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
#bind-address = 127.0.0.1
- 给远程用户赋权限
grant all on *.* to user_name@'%' identified by 'password';
上面的命令使得该用户可以访问所有的数据库和表。
- 最后重启mysql服务器,就可以远程访问此数据库了。
sudo /etc/init.d/mysql restartsudo /etc/init.d/mysql restart
参考资料:
http://wenku.baidu.com/view/7273fb1ffad6195f312ba68c.html
http://www.blogjava.net/yjhmily/articles/336926.html