MySQL Commands

  1. Login:
    mysql -uroot -ptest1234;
  2. Show password policy:
    show variables like 'validate_password%';
  3. Show all databases
    show databases;
  4. Backup DB:
    mysqldump -u root -p linux > /home/beinan/linuxsir031130.sql
  5. Import DB:
    mysql -u root -p linux < /home/beinan/linuxsir031130.sql
  6. Create a new user:
    CREATE USER 'user'@'localhost' IDENTIFIED BY 'yourpassword';
    
    GRANT ALL PRIVILEGES ON dbname.* TO 'user'@'localhost';
    
    FLUSH PRIVILEGES;

    Note:

    1. ‘user’@’localhost’ 後面的localhost是指可以存取DB的IP,不是DB server的IP
    2. yourpassword不需要填加密的,直接用明碼就可以了
    3. ‘10.0.1.%’ could be replaced with ‘localhost’
      Password generator: https://www.browserling.com/tools/mysql-password

Creating an user with adminer:

  • 如果要讓user透過adminer登入,目前測試server欄位是一定要填%

Referece:

  1. https://www.opencli.com/mysql/mysql-add-new-users-databases-privileges