Import 1 file sql lớn trên MacOS
Vào thư mục chứa Mysql: cd /Applications/MAMP/Library/bin
Login vào Mysql: /Applications/MAMP/Library/bin/mysql –host=localhost -uroot -proot
Chọn database sẽ import vào: use showrommecauto
Chạy file sql: source đường dẫn
Ví dụ: source /Users/obamavstrump/Documents/mysql.sql
Thao tác với user
Chú ý: Linux phân quyền rất tốt, cho nên khi tạo file hay thư mục cần nhớ đến group và user chứ không sau này không có quyền ghi vào file hay xóa file đâu.
Ví dụ:
- user nhóm này ko thể làm gì với file của nhóm khác
-
1 file ko phải ko của mình thì ko thể làm đc gì trừ khi trong nhóm của ngừoi chủ sở hữu file đó và phải để permission là 775
1 Liệt kê user:
cut -d: -f1 /etc/passwd
2 Tạo user mới
sudo adduser tomtom
3 Xóa user
sudo userdel tomtom
Xóa luôn cả thư mục của user trong thư mục home: sudo rm -r /home/tomtom
4 Sửa thông tin user
sudo usermod -l tomtomnewuser tomtomuser
5 Nén 1 folder
tar -cvzf may_arch.tar.gz my_folder
6 Giải nén
tar -xvzf may_arch.tar.gz
7. Set lại cho folder thuộc sở hữu user khác
sudo chown -R www-data:www-data /var/www
8. Set lại cho folder thuộc sở hữu user khác
Thêm 1 user vào nhóm nào đó. Ví dụ thêm dotrinhgoogle vào nhóm www-data
1 |
sudo usermod -a -G www-data dotrinhgoogle |
Xem user hiện tại nằm trong những nhóm nào
1 |
groups |
Xem tất cả nhóm đang có trong hệ thống.
1 |
getent group |
Xóa 1 user khỏi 1 nhóm
1 |
sudo deluser www-data dotrinhgoogle |
Làm việc với Folder
1 Nén 1 folder thành file tar.gz
tar -cvzf may_arch.tar.gz my_folder
2 Xả nén
tar -xvzf may_arch.tar.gz
Bên dưới có 1 cách khác
Set lại quyền cho folder
sudo chmod -R 755 tenfolder/
Thay đổi tên Folder
mv tên_cũ tên_mới
Không tạo file và sửa file được qua filezilla
1 2 3 4 5 6 7 8 9 10 |
1. Thêm user vào nhóm sudo usermod -a -G www-data dotrinhgoogle 2. Thay đổi sở hữu thuộc nhóm nào sudo chgrp -R www-data /var/www/html 3. Thay đổi quyền ghi sudo chmod -R g+w /var/www/html 4. Exit và đăng nhập lại |
Kết nối Google CLoud bằng ssh và sftp
1 2 3 4 5 6 7 8 |
-> lấy key ssh-keygen -t rsa -f ~/.ssh/wp-ssh-key -C tencuaban -> Thiết lập quyền chmod 400 ~/.ssh/wp-ssh-key -> add key vào GC -> copy key ra desktop -> Logon file: file type -> protocol sftp -> chọn key ngoài desktop -> username là cái tên trong rsa_key |
- Để hiện các thư mục ẩn, cụ thể là thư mục .ssh dùng tổ hợp phím: Shift+Command+dấu chấm
Đăng nhập bằng ssh trong terminal
cd ~/.ssh/
ssh -i wp-ssh-key [email protected]
Xem thông tin hệ điều hành Linux đang chạy
uname -a
Đăng nhập vào VPS bằng SSH
ssh -i ../path/duongdandenfile.pem [email protected]_DNS_cua_ban_(ec2-13-114-167-200.ap-northeast-1.compute.amazonaws.com)
ZIP file trong Linux
zip -r myfiles.zip mydir
UNZIP file trong Linux
Cài nếu chưa có: sudo apt-get install unzip
Giải nén: sudo unzip dosm.zip
Download file từ internet
sudo wget http://websgle.dotrinh.com/download.zip
Copy 1 File
sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/example.com.conf
copy file tên là 000-default.conf ra 1 file mới là example.com.conf
Xóa file
sudo rm file.zip
Xóa thư mục
sudo rm -r folder
Xóa toàn bộ file trong 1 thư mục
1 |
rm -rf /path/to/directory/* |
LÀM VIỆC VỚI MySQL
Start:
1 2 |
sudo /etc/init.d/mysql start |
Stop:
1 2 |
sudo /etc/init.d/mysql stop |
Restart / reload configs:
1 2 |
sudo /etc/init.d/mysql restart |
Check run status:
1 |
sudo /etc/init.d/mysql status |
Bị lỗi khi import một đoạn SQL
Unknown collation: ‘utf8mb4_unicode_520_ci’
chỉ cần thay thế utf8mb4_unicode_520_ci
with utf8mb4_unicode_ci
là ok
Các bài viết không xem thì tiếc:
- Cài đặt LAMP trên AWS EC2
- Thêm nhiều domain trong Apache – Web Server
- Lỗi 404 Not Found WordPress trên Apache
Vừa bình luận