删除已安装的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-common
清理残留数据
dpkg -l |grep ^rc|awk '{print $2}' |sudo xargs dpkg -P
</pre><p>安装mysql:</p><pre code_snippet_id="492728" snippet_file_name="blog_20141022_4_5574634" name="code" class="plain">sudo apt-get install mysql-server
sudo apt-get install mysql-client
sudo apt-get install php5-mysql(用于连接php和mysql)
查看mysql是否运行
ps aux | grep mysql
启动命令
/etc/init.d/mysql start
修改编码
修改/etc/my.cnf 中的设置,在[client]节点下添加
default-character-set=utf8
在[mysqld]节点下添加
character-set-server=utf8
collation-server=utf8_general_ci
将/etc/my.cnf 中的 bind-address = 127.0.0.1 用 '#' 注掉
执行命令
mysql
执行sql
use mysql;
update user set host = '%' where user = 'root';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;