Tag Archives: db

mongo mongoshell query examples

mongo mongoshell query examples

db.MYTABLE.find()
db.MYTABLE.find({}).count
db.MYTABLE.find({}).limit(10)
db.MYTABLE.find({"name":"a"})
db.MYTABLE.find({"name":"a"},{name:1})
db.MYTABLE.find({"name":"a"}).sort({name:1})
db.MYTABLE.remove({"name":"a"})

 

MS SQL Server SQLExpress 2014 TCP/IP

MS SQL Server 2014 SQL Express 2014 TCP/IP connections

SQL Server 2014 / SQL Express 2014

  • Enable MS SQL Server TCP/IP connections
  • Restart MS SQL Server
  • Check MS SQL Server Log for port being used
  • This may not be 1433 but might be 49445 instead
  • Enable port through firewall

SQL Server Client

  • Run Sql Server 2014 Managerment Studio
  • Connect via Server Name or IP and specify Port after a comma
    • MYSERVER,1433
    • 10.10.10,10,49445

GNU/Linux PHP PDO MS SqlServer & ODBC connectors and drivers

GNU/Linux PHP PDO MS SqlServer & ODBC connectors and drivers

mariadb, mysql and percona 5.5 general query and slow query logging

mariadb, mysql and percona 5.5 general query and slow query logging

mysql> select @@general_log;
+---------------+
| @@general_log |
+---------------+
|             1 |
+---------------+


mysql> select @@general_log_file;
+-------------------------------+
| @@general_log_file            |
+-------------------------------+
| /var/lib/mysql/data/query.log |
+-------------------------------+


mysql> select  @@slow_query_log;
+------------------+
| @@slow_query_log |
+------------------+
|                1 |
+------------------+


mysql> select @@slow_query_log_file;
+------------------------------------+
| @@slow_query_log_file              |
+------------------------------------+
| /var/lib/mysql/data/mysql-slow.log |
+------------------------------------+

ubuntu 14.04 (trusty) percona 5 install howto

https://www.percona.com/doc/percona-server/5.5/installation/apt_repo.html

howto switch from mysql 5 to percona 5 on ubuntu 14.04 trusty

remove mysql (if youve already installed it)

# aptitude remove mysql-client-5.5 mysql-client-core-5.5 mysql-workbench

install percona

# apt-key adv --keyserver keys.gnupg.net --recv-keys 1C4CBDCDCD2EFD2A
# vi /etc/apt/sources.list

  deb http://repo.percona.com/apt trusty main
  dpkg http://repo.percona.com/apt trusty main
  
# aptitude update
# aptitude install percona-server-client-5.5 percona-server-server-5.5

#mysql howto convert a database and it tables to #utf8

DUMP
mysqldump -h 127.0.0.1 -uMYUSER –skip-quote-names –skip-comments –skip-extended-insert MYDATABASE > db.sql

MODIFY
mysql > alter database MYDATABASE character set = utf8 collate = utf8_general_ci;

PATCH
sed “s/ENGINE=MyISAM/ENGINE=InnoDB/g” < db.sql > db2.sql
sed “s/DEFAULT CHARSET=latin1;/;/g” < db2.sql > db3.sql
sed “s/CHARACTER SET utf8 COLLATE utf8_bin//g” < db3.sql > db4.sql

.MY.CNF
[client]
default-character-set=utf8

RESTORE
mysql -h 127.0.0.1 -uMYUSER < db4.sql

CHECK NEW SETTINGS
mysql > show variables

| character_set_client                    | utf8                       
| character_set_connection                | utf8                       
| character_set_database                  | utf8                       
| character_set_filesystem                | binary                     
| character_set_results                   | utf8                       
| character_set_server                    | latin1                     
| character_set_system                    | utf8                    
   
| collation_connection                    | utf8_general_ci            
| collation_database                      | utf8_general_ci            
| collation_server                        | latin1_swedish_ci

Refs