ubuntu14.04直接用命令行安装mysql数据库

今天在Ubuntu 14.04下安装MySQL,原本是去官网下载安装包来安装的,但是安装以后却不能用,估计是要配置吧,在网上搜了不少的资料,结果仍是失败。因此只好在软件源中安装,这样就省去不少没必要要的麻烦了。mysql

www.linuxidc.com@linuxidc :~$ sudo apt-get install mysql-server
[sudo] password for linuxidc:linux

Ubuntu 14.04下安装MySQL

执行该命令后,系统还会自动安装其它的一些软件,在安装过程当中会提示输入mysql的登入密码。sql

Ubuntu 14.04下安装MySQL

使用Tab键选择肯定数据库

Ubuntu 14.04下安装MySQL

上图,要输入两次密码,我这里就输入v,测试用吗。简单点,记住,后面要用到。
 
若是系统版本不同,提示的方式可能不同,不过整体来讲都差很少。安装好后,执行命令ubuntu

www.linuxidc.com@linuxidc :~$ mysql
ERROR 1045 (28000): Access denied for user 'linuxidc'@'localhost' (using password: NO)
www.linuxidc.com@linuxidc :~$测试

Ubuntu 14.04下安装MySQL

结果出现错误,Google了半天,结果愈来愈没耐心,这时候翻了翻本身买的书籍,输入了下面的命令spa

www.linuxidc.com@linuxidc :~$ mysql -uroot -pv.net

Ubuntu 14.04下安装MySQL

其中第一个mysql是命令,-uroot是指定用户为root,-pv是输入登入密码,v是密码,若是你设置的密码是别的,就换成本身安装时设置的密码,切记密码和-p之间不要有空格,否则会失败的。下面是我成功登入后,查看当前全部存在的数据库。server

linuxidc@ubuntu :~$ mysql -uroot -pv
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 44
Server version: 5.5.37-0ubuntu0.14.04.1 (Ubuntu)get

Copyright (c) 2000, 2014, 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>

相关文章
相关标签/搜索