zoukankan      html  css  js  c++  java
  • MySQL常用技巧

    1.查看MySQL版本信息:

      1,登上 mysql>status;

      2,登上 mysql>select version();

      3,登上 mysql> select @@version;

      4,不登 [root@localhost ~]# mysql -V

      5,不登 [root@localhost ~]# mysql --help | grep Distrib ;

    2.MySQL服务启动:

      1,window下启动服务 net start mysql

      2,window下停止服务 net stop mysql

      3,linux下启动服务 service mysql start

      4,linux下停止服务 service mysql stop

    3.当系统上启动多个端口的MySQL的时候:

      1,连接的方式:mysql -uroot -proot@2015 -P 3306-S /mysqldata/database/data3306/mysql1.sock

      2,当出现链接不上的问题执行下面的命令:

        a)mysql>grant all privileges on *.* to username@"%" identified by "password" with grant option;

        b)mysql>flush privileges;

    4.MySQL的一些常用的查看命令:

      1,查看数据库 mysql>show databases;

      2,选择数据库 mysql>use databasesname;

      3,查看数据库中存在的函数 mysql> show function status;

      4,查看视图 mysql>select * from information_schema.VIEWS;

      5,查看表 mysql>show tables;

      6,查看触发器 mysql>show triggers;

      7,查看当前用户 mysql> select user();

      8,查看所有用户 mysql>select  user,host,password from mysql.user;

      9,查看MySQL字符集 mysql>show variables like '%char%';

      10,查看数据库的字符集 mysql>show create database databasename;

      11,查看表的字符集 mysql>show create table databasename.tablename G;

      12,查看当前选择的数据 mysql>select database();

      13,查看用户权限 show grants for 'esopapp’;

      14,最大连接数:show variables like '%max_connections%';

      15,当前连接数:show full processlist;

      16,导出数据库 mysqldump -uroot -p 数据库名 > D:导出文件名.sql

      17,导出表数据 mysqldump -uroot -p 数据库名 表名> D:导出文件名.sql

    5.MySQL对表和数据的一些操作命令:

      1, 将文本文件的数据装载到表中:mysql>Load data local infile "mytable.txt" into table mytable;

      2,给字段增加 primary key : mysql> alter table tablename add primary key(id);

      3,删除primary key:   mysql>alter table tablename drop primary key; 或者 mysql>drop primary key on tablename;

      4,添加新字段 :mysql>alter table tablename add column columnname char(1);或者 mysql>alter table tablename add field int(11) nosiged not null; 

      5,删除字段: mysql>alter table tablename drop column c;

      6,在列d上增加一个索引,并且使列a为主键: mysql>alter table tablename index(d),add primary key(a);

      7,增加一个新的AUTO_INCREMENT整数列,命名为c : mysql>alter table tablename add c int unsigned not null auto_increment  ,add index(c);

    6.MySQL操作出现问题的解决办法:

      1,出现function不能建立:

        mysql>show variables like 'log_bin_trust_function_creators';

        mysql>set global log_bin_trust_function_creators=1;

      2,字符集设置:

          [client]

          default-character-set=utf8

            [mysqld]

          default-storage-engine=INNODB

          character-set-server=utf8

          collation-server=utf8_general_ci

      3,Mysql too many connection

        max_connections=1000 //注意就是加上这个,还是不行

        wait_timeout=5//再加上这个,这个文件中有可能,没有这两个值,再后边添加上就行了,注意

  • 相关阅读:
    Azure HDInsight 现已在中国正式发布
    避免由于Windows Update自动安装安全补丁导致VM意外重启
    如何修复在Microsoft Azure中“虚拟机防火墙打开,关闭RDP的连接端口”问题
    关于Azure Auto Scale的高级属性配置
    在Azure中使用Load Runner测试TCP最大并发连接数
    Windows Azure案例分析: 选择虚拟机或云服务?
    Windows Server基础架构云参考架构:硬件之上的设计
    浅析基于微软SQL Server 2012 Parallel Data Warehouse的大数据解决方案
    在Windows Azure公有云环境部署企业应用
    如何在后台运行_Linux_命令并且将进程脱离终端
  • 原文地址:https://www.cnblogs.com/junhuijiang/p/4776445.html
Copyright © 2011-2022 走看看