MySql的安装和使用

ubuntu上安装MySQL非常简单只需要几条命令就可以完成。

  1. sudo apt-get install mysql-server
 
  2. apt-get isntall mysql-client
 
  3.   sudo apt-get install libmysqlclient-dev
 
  安装过程中会提示设置密码什么的,注意设置了不要忘了安装完成之后可以使用如下命令来检查是否安装成功:
 
   sudo netstat -tap | grep mysql
 
  通过上述命令检查之后,如果看到有mysql 的socket处于 listen 状态则表示安装成功。
 
  登陆mysql数据库可以通过如下命令:
 
   mysql -u root -p 
 
  -u 表示选择登陆的用户名, -p 表示登陆的用户密码,上面命令输入之后会提示输入密码

Mysql错误:Ignoring query to other database解决方法

今天登陆mysql show databases出现Ignoring query to other database错误,又试了几个命令和sql全部提示Ignoring query to other database错误

错误如下:

D:\Program Files\MySQL\MySQL Server 5.6\bin>mysql -root
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 66
Server version: 5.6.15 MySQL Community Server (GPL)

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> show databases;
Ignoring query to other database
mysql> show tables;
Ignoring query to other database

折腾了半天才发现原来是在连接mysql时没有"-u"参数导致的
D:\Program Files\MySQL\MySQL Server 5.6\bin>mysql -uroot

重新连接mysql 加上-u参数 一切正常

创建数据库(转载):

1) 建立一个名为xhkdb的数据库:
    mysql> create database xhkdb;

2) 创建数据库并分配用户:

  1. CREATE DATABASE 数据库名;
  2. GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,ALTER ON 数据库名.* TO 数据库名@localhost IDENTIFIED BY '密码';
  3. SET PASSWORD FOR '数据库名'@'localhost' = OLD_PASSWORD('密码');
依次执行3个命令完成数据库创建。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值