乌班图mysql解压过程_mysql在ubuntu上的安装过程

1、安装mysql-server:

hadoop@stcn501a0166:~$ mysql

程序 'mysql' 已包含在下列软件包中:

* mysql-client-core-5.5

* mariadb-client-core-5.5

* mysql-client-core-5.6

* percona-xtradb-cluster-client-5.5

请尝试:sudo apt-get install

hadoop@stcn501a0166:~$ sudo apt-get install mysql-server

[sudo] password for hadoop:

正在读取软件包列表... 完成

正在分析软件包的依赖关系树

正在读取状态信息... 完成

说明:遇到输入的地方输入Y,过程中需要设置root用户的密码,设置时记住密码

2、root用户登录:

hadoop@stcn501a0166:~$ mysql -u root -p

Enter password:

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 48

Server version: 5.5.44-0ubuntu0.14.04.1 (Ubuntu)

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

3、查看系统中的数据库:

mysql> show databases;

+--------------------+

| Database |

+--------------------+

| information_schema |

| mysql |

| performance_schema |

+--------------------+

3 rows in set (0.00 sec)

mysql>

4、新建测试用数据库:

mysql> create database example;

Query OK, 1 row affected (0.00 sec)

mysql> show databases;

+--------------------+

| Database |

+--------------------+

| information_schema |

| example |

| mysql |

| performance_schema |

+--------------------+

4 rows in set (0.00 sec)

mysql>

5、创建新的用户帐号:

mysql> create user 'mzuser'@'localhost' identified by '123456';

Query OK, 0 rows affected (0.00 sec)

mysql> grant all on example.* To 'mzuser'@'localhost';

Query OK, 0 rows affected (0.00 sec)

说明:给用户赋予在example数据库上的权限

6、使用新用户登录

hadoop@stcn501a0166:~$ mysql -u mzuser -p

Enter password:

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 49

Server version: 5.5.44-0ubuntu0.14.04.1 (Ubuntu)

Copyright (c) 2000, 2015, 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> show databases;

+--------------------+

| Database |

+--------------------+

| information_schema |

| example |

+--------------------+

2 rows in set (0.00 sec)

mysql>

7、修改用户访问的数据库并查看库中表

mysql> use example

Database changed

mysql> show tables;

Empty set (0.00 sec)

mysql> exit

由于新创建的库中没有任何表,所以显示为empty

8、退出登录并关闭数据库服务:

sql>exit

~$sudo /etc/init.d/mysql stop

9、测试创建表(使用新建用户登录,use example数据库)

mysql> create table CmsUser(

> userid int(8) not null auto_increment primary key,

>username varchar(20) not null,

> password varchar(20),

> area varchar(10),

>deptrole varchar(10));

Query OK, 0 rows affected (0.06 sec)

mysql> show tables;

+-------------------+

| Tables_in_example |

+-------------------+

| CmsUser |

+-------------------+

1 row in set (0.00 sec)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值