Ubuntu12.04下安装、使用、卸载MySQL

转自:http://blog.csdn.net/yimi0903/article/details/11800713


一、安装

    Step1:安装MySQL-server,mysql-client

        执行以下命令:

[html] view plain copy
  1. sudo apt-get install mysql-server  
        出现此图,需要设置数据库用户root的密码,并且按回车键后需要再次输入。


        执行以下命令:

[html] view plain copy
  1. sudo apt-get install mysql-client  
        执行以下命令,查看是否安装成功。
[html] view plain copy
  1. sudo netstat -tap | grep mysql  
        mysql安装完成后会直接启动,因此出现类似如下命令,则安装成功。

        tcp 0 0 localhost:mysql *:* LISTEN 15320/mysqld

        如果mysql没有启动,执行以下命令启动mysql:

[html] view plain copy
  1. sudo /etc/init.d/mysql restart  

    Step2:安装要和C 语言连接是的MySql的库文件和头文件

        执行以下命令:

[html] view plain copy
  1. sudo apt-get install libmysqlclient15-dev  

        执行以下命令,查看是否安装成功:

[html] view plain copy
  1. cd /usr/include/mysql        (查看是否有头文件)  
  2. cd /usr/lib/mysql            (查看是否有库文件)  

二、使用

    1、执行以下命令,进入mysql:

[html] view plain copy
  1. sudo mysql -u root -p       (注意修改用户名)  
    2、执行Ctrl+D命令,退出mysql。


三、卸载

    依次执行以下命令:

[html] view plain copy
  1. sudo 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  
  5. dpkg -l |grep ^rc|awk '{print $2}' |sudo xargs dpkg -P   (清理残留数据)  

====================================依米花的分割线====================================

1、参考资料:

    http://blog.csdn.net/mzlqh/article/details/7621307

    http://renyan.spaces.eepw.com.cn/articles/article/item/84750

posted @ 2016-10-18 12:51  隔壁王叔叔a  阅读(399)  评论(0编辑  收藏  举报