Danh mục: Mysql
-
import mysql with special port
mysql -h 127.0.0.1 -P 3307 -uroot -p db_name < /db.sql
-
Moving server with docker, rsync
sudo docker ps #Show container id #chat service sudo docker exec -i {CONTAINER_ID} /usr/bin/mongodump –uri “mongodb://” –archive > /mnt/storage/mongodb.dump sudo docker exec -i {CONTAINER_ID} /usr/bin/mongorestore –uri “mongodb://” –archive –drop < /mnt/storage/mongodb.dump #database sudo docker exec -i {CONTAINER_ID} mysql -uhanda -p{PASSWORD} handa < /mnt/storage/database.sql #storage log sudo rsync -avh target_server:/var/www/storage/ /mnt/storage/
-
Config remote mysqldump without password
Edit: ~/.my.cnf [mysqldump] user=root password=123456
-
Create user database mysql
CREATE USER ‘blogs’@’localhost’ IDENTIFIED BY ‘PASSWORD’; CREATE DATABASE blogs ; GRANT ALL PRIVILEGES ON blogs.* TO ‘blogs’@’localhost’; FOR REMOTELY: GRANT ALL ON *.* to ‘blogs’@’%’ IDENTIFIED BY ‘password’ WITH GRANT OPTION; FLUSH PRIVILEGES; GRANT ALL PRIVILEGES ON blogs.localhost TO ‘blogs‘@’%’;
-
sql_mode=only_full_group_by
sql_mode=only_full_group_by mysql > SET GLOBAL sql_mode=(SELECT REPLACE(@@sql_mode,’ONLY_FULL_GROUP_BY’,”));
-
Create database mysql
CREATE USER ‘blogs’@’localhost’ IDENTIFIED BY ‘PASSWORD’; CREATE DATABASE blogs; GRANT ALL PRIVILEGES ON blogs .* TO ‘blogs’@’localhost’; FLUSH PRIVILEGES;