Kategoria - MySQL i inne bazy - liczba wpisów 13
MySQL, MongoDB, Postgres, Firebird

Podczas importu bazy z pliku:

mysql -u root -ppassword -h localhost database < database.sql

Wyskoczył błąd:

ERROR 1153 (08S01) at line 2494: Got a packet bigger than 'max_allowed_packet' bytes

Rozwiązanie:

mysql --max_allowed_packet=100M -u root -ppassword -h localhost database < database.sql

Źródło: https://stackoverflow.com/questions/93128/mysql-error-1153-got-a-packet-bigger-than-max-allowed-packet-bytes

Postgrep - Install od Debian Kategoria: MySQL i inne bazy | Tagi: postgres | Autor: Bartłomiej Gałęzia

aptitude install postgresql postgresql-contrib php-pgsql

check version

sudo -u postgres psql -c "SELECT version();"
vim /etc/postgresql/11/main/pg_hba.conf
local all postgres trust
service postgresql restart
sudo su - postgres -c "createuser miethek" //create user
sudo su - postgres -c "createdb empg" //create db
GRANT ALL PRIVILEGES ON DATABASE empg TO miethek;

Połączenie z innych adresów:

vim /etc/postgresql/11/main/postgresql.conf
listen_addresses = '*'
vim /var/lib/pgsql/data/pg_hba.conf
host  all  all 0.0.0.0/0 md5
service postgresql restart

Źródło: https://linuxize.com/post/how-to-install-postgresql-on-debian-10/

Występuje przy przełączaniu na php5.6 w ubuntu 20.

Rozwiązanie:

1. ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'pass';

2. Na końcu pliku /etc/mysql/my.cnf dodać:

[client]
default-character-set=utf8

[mysql]
default-character-set=utf8

[mysqld]
collation-server = utf8_unicode_ci
character-set-server = utf8
default-authentication-plugin=mysql_native_password

SELECT pagename, COUNT(DISTINCT ipaddress) AS visit_count FROM log_visitors GROUP BY pagename ORDER BY visit_count DESC;

Źródło: https://stackoverflow.com/questions/1841426/is-it-possible-to-group-by-multiple-columns-using-mysql

vim /etc/mysql/my.cnf

or

vim /etc/mysql/mariadb.conf.d/50-server.cnf #Debian 10
bind-address           = 0.0.0.0
sudo service mysql restart
mysql -uroot -p
use ocsdb;
GRANT ALL ON ocsdb.* TO ocsuser@'192.168.0.1' IDENTIFIED BY 'ocspassword';
FLUSH PRIVILEGES;

https://linuxize.com/post/mysql-remote-access/

ERROR 1153 (08S01) at line 4025: Got a packet bigger than 'max_allowed_packet' bytes

vim /etc/mysql/mysql.conf.d/mysqld.cnf
max_allowed_packet = 512M
vim /etc/mysql/conf.d/mysqldump.cnf
max_allowed_packet = 512M
service mysql restart

In file:

/etc/mysql/mysql.conf.d/mysqld.cnf

add

show_compatibility_56 = On
sudo service mysql restart

Źródło: https://stackoverflow.com/questions/45496268/mysql-5-7-show-compatibility-56

Przy zapytaniu i rozmiar bazy danych:

SELECT * , sum( data_length + index_length ) AS db_size_mb FROM information_schema.TABLES WHERE table_schema = 'crm' GROUP BY table_schema ;

Dostaję taki błąd:

#1055 - Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'information_schema.TABLES.TABLE_CATALOG' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by

Naprawa:

sudo vim /etc/mysql/conf.d/mysql.cnf

Dodaj:

[mysqld]
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

i restart usługi:

sudo service mysql restart

Źródło: https://stackoverflow.com/questions/37951742/1055-expression-of-select-list-is-not-in-group-by-clause-and-contains-nonaggr

Wersja #2

SET GLOBAL sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));

Źródło: https://stackoverflow.com/questions/23921117/disable-only-full-group-by

Wersja #3

sudo vim /lib/systemd/system/mysql.service
ExecStart=/usr/sbin/mysqld --sql-mode=STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION
systemctl daemon-reload
sudo service mysql restart

Źródło: https://serverfault.com/questions/1019823/cannot-set-sql-mode-to-mysql-8

W nowej wersji phpmyadmin nie ma możliwości logowania się przez konto root.

Aby to obejść należy stworzyć nowego użytkownika do bazy.

sudo mysql --user=root mysql
CREATE USER 'username'@'localhost' IDENTIFIED BY 'userpass';
GRANT ALL PRIVILEGES ON *.* TO 'username'@'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;

Mysql DUMP i Restore Kategoria: MySQL i inne bazy | Tagi: mysqldump, mysql | Autor: Bartłomiej Gałęzia

mysqldump -p --user=username database_name > zrzut_bazy.sql

mysql -u user -ppass -h localhost database_name < /home/www/zrzut_bazy.sql

Reset mysql root password Kategoria: MySQL i inne bazy | Tagi: mysql, pass, reset | Autor: Wojciech Gazda

http://www.rackspace.com/knowledge_center/article/mysql-resetting-a-lost-mysql-root-password

sudo /etc/init.d/mysql stop
sudo mysqld_safe --skip-grant-tables &
mysql -uroot
use mysql;
update user set password=PASSWORD("mynewpassword") where User='root';
flush privileges;
quit
sudo /etc/init.d/mysql stop && sudo /etc/init.d/mysql start
mysql -u root -p

MongoDB - dokumentacja Kategoria: MySQL i inne bazy | Tagi: mongoDB | Autor: Bartłomiej Gałęzia

Książka: NoSQL Distilled: A Brief Guide to the Emerging World of Polyglot Persistence, Pramodkumar J. Sadalage
Na stronie http://ukbooks.pl/pl/book/NoSQL-Distilled-9780321826626 jest podany koszt 19.43 EUR + darmowa przesyłka

NoSQL Databases, Christof Strauch – bardzo ciekawa pozycja
Scalable SQL and NoSQL Data Stores, Rick Cattell
NoSQL Evaluation A Use Case Oriented Survey, Robin Hecht, Stefan Jablonski
Comparative Study of the New Generation, Agile, Scalable, High Performance NOSQL Databases, Clarence J M Tauro, Aravindh S, Shreeharsha A.B
Analysis and Classification of NoSQL Databases and Evaluation of their Ability to Replace an Object-relational Persistence Layer, Kai Orend
A comparison between several NoSQL databases with comments and notes, Tudorica, Bogdan George – niestety, ja nie mam do tej pozycji dostępu

http://en.wikipedia.org/wiki/NoSQL#Key.E2.80.93value_store

http://cattell.net/datastores/

http://nosql-database.org/

http://highlyscalable.wordpress.com/2012/03/01/nosql-data-modeling-techniques/

http://metadata-standards.org/Document-library/Documents-by-number/WG2-N1501-N1550/WG2_N1537_SQL_Standard_and_NoSQL_Databases%202011-05.pdf

http://nosql.findthebest.com/

http://highscalability.com/anti-rdbms-list-distributed-key-value-stores

http://www.versant.com/docs/default-document-library/nosql—beyond-the-key-value-store-for-the-enterprise_wp_low_res.pdf?sfvrsn=2

http://www.neo4j.org/learn/nosql

MongoDB on windows Kategoria: MySQL i inne bazy | Tagi: windows, mongoDB | Autor: Bartłomiej Gałęzia

Download:

http://www.mongodb.org/downloads

http://downloads.mongodb.org/win32/mongodb-win32-x86_64-2.2.3.zip

unzip to c:\mongo

C:\mongo\bin\mongod.exe –dbpath C:\mongo\data            //server

C:\mongo\bin\mongo.exe //klient

db.test.save( { a: 1 } )

db.test.find()

md C:\mongo\log

md C:\mongo\data\db

echo logpath=C:\mongo\log\mongo.log > C:\mongo\mongod.cfg

echo dbpath=C:\mongo\data >> C:\mongo\mongod.cfg

C:\mongo\bin\mongod.exe –config C:\mongo\mongod.cfg –install

net start MongoDB

Wyszukaj

Zapisz się do newsletera