ubuntu笔记4_mysql数据库安装

来源:互联网 发布:js font 赋值 编辑:程序博客网 时间:2024/05/16 05:44

1、安装mysql

sudo apt-get install mysql-serversudo 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 43Server 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 itsaffiliates. Other names may be trademarks of their respectiveowners.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.02 sudo apt-get remove mysql-server3 sudo apt-get autoremove mysql-server4 sudo apt-get remove mysql-common (非常重要)

清理残留数据

dpkg -l |grep ^rc|awk '{print $2}' |sudo xargs dpkg -P


原创粉丝点击