play mysql on mac

  1. install
    google instal mysql community mac
  2. start server
    cd /usr/local/mysql-8.0.25-macos11-x86_64/support-files
    sudo ./mysql.server start
    sudo killall mysqld
    cd /usr/local
    sudo chown -R mysql mysql-8.0.25-macos11-x86_64
    cd mysql-8.0.25-macos11/support-files
    sudo ./mysql.server start
  3. log in
    cd /usr/local/mysql-8.0.25-macos11-x86_64/bin
    ./mysql -u root -p
  4. log out
    mysql> exit
  5. list databases
    mysql> show databases;
  6. create database
    mysql> create database test_db;
  7. change/switch database
    mysql> use test_db;
  8. list tables
    mysql> show tables;
  9. create user
    -- login as root user
    mysql> create user 'test'@'localhost' identified by 'test0';
  10. grant privileges to user
    mysql> grant all privileges on test_db.* to 'test'@'localhost';
    mysql> flush privileges;
    mysql> exit;
    ./mysql -u test -p
    mysql> show databases; -- should be able to see test_db but not sys

你可能感兴趣的:(play mysql on mac)