Mac install and open mysql using terminal

后端 未结 10 1313
你的背包
你的背包 2021-01-29 19:29

I downloaded the mysql dmg file and went through the wizard to run. Done. I have also started mysql server under system preferences.

The purpose of me doing this is to w

相关标签:
10条回答
  • 2021-01-29 19:46

    In the terminal, I typed:

    /usr/local/mysql/bin/mysql -u root -p
    

    I was then prompted to enter the temporary password that was given to me upon completion of the installation.

    0 讨论(0)
  • 2021-01-29 19:49

    In MacOS, Mysql's executable file is located in /usr/local/mysql/bin/mysql and you can easily login to it with the following command:

    /usr/local/mysql/bin/mysql -u USERNAME -p
    

    But this is a very long command and very boring, so you can add mysql path to Os's Environment variable and access to it much easier.

    For macOS Catalina and later

    Starting with macOS Catalina, Mac devices use zsh as the default login shell and interactive shell and you have to update .zprofile file in your home directory.

    echo 'export PATH="$PATH:/usr/local/mysql/bin"' >> ~/.zprofile
    source ~/.zprofile
    mysql -u USERNAME -p
    

    For macOS Mojave and earlier

    Although you can always switch to zsh, bash is the default shell in macOS Mojave and earlier and with bash you have to update .bash_profile file.

    echo 'export PATH="$PATH:/usr/local/mysql/bin"' >> ~/.bash_profile
    source ~/.bash_profile
    mysql -u USERNAME -p
    
    0 讨论(0)
  • 2021-01-29 19:51
    1. install homebrew via terminal

    2. brew install mysql

    0 讨论(0)
  • 2021-01-29 19:55

    (Updated for 2017)

    When you installed MySQL it generated a password for the root user. You can connect using

    /usr/local/mysql/bin/mysql -u root -p
    

    and type in the generated password.

    Previously, the root user in MySQL used to not have a password and could only connect from localhost. So you would connect using

    /usr/local/mysql/bin/mysql -u root
    
    0 讨论(0)
  • 2021-01-29 19:57

    open terminal and type

    sudo sh -c 'echo /usr/local/mysql/bin > /etc/paths.d/mysql'
    

    then close terminal and open a new terminal and type

    mysql -u root -p
    

    hit enter, and it will ask you for password

    I have found this solution on https://teamtreehouse.com/community/says-mysql-command-not-found

    now to set new password type

    ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';
    
    0 讨论(0)
  • 2021-01-29 20:05

    For mac OS Catalina :

    /usr/local/mysql/bin/mysql -uroot -p
    

    This will prompt you to enter password of mysql

    0 讨论(0)
提交回复
热议问题