1、安装mysql
sudo apt-get install mysql-server
sudo apt-get install mysql-client
注意在安装mysql-server时会显示让你输入mysql的root密码这里一定输入,不然mysql的管理员账户就会无密码。 mysql -u root -p 管理员密码就无法使用
2、检查MySql是否启动
sudo netstat -tap | grep mysql
若出现
tcp 0 0 localhost:mysql *:* LISTEN 15700/mysqld
即表示MySQL已启动(注意显示的时间会比较长,要耐心等待)
若没有运行则可以通过
sudo /etc/init.d/mysql restart
命令来启动MySQL
3、进入MySQL
$mysql -u root -p 管理员密码
这里若上面的命令中没有 -p这会显示错误
sazabi@sazabi-MS-7751:~$ mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 43
Server version: 5.5.32-0ubuntu0.13.04.1 (Ubuntu)
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
若想推出输入
mysql> \q
即可
4、删除MySQL
1sudo apt-get autoremove --purge mysql-server-5.0
2 sudo apt-get remove mysql-server
3 sudo apt-get autoremove mysql-server
4 sudo apt-get remove mysql-common (非常重要)
清理残留数据
dpkg -l |grep ^rc|awk '{print $2}' |sudo xargs dpkg -P