mac安装mysql

/ 技术相关 / 0 条评论 / 1100浏览

使用安装包安装mysql

    (1).进入/usr/local/mysql/bin,查看此目录下是否有mysql。
    (2).执行vim ~/.bash_profile,在该文件中添加mysql/bin的目录:
            PATH=$PATH:/usr/local/mysql/bin
            添加完成后,按esc,然后输入wq保存。
        最后在命令行输入source ~/.bash_profile
    SET PASSWORD FOR 'root'@'localhost' = PASSWORD('newpass');

允许外网访问MySQL

    mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'mypwd' WITH GRANT OPTION;
    mysql> flush privileges;
    mysql> GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'192.168.1.102' IDENTIFIED BY 'mypwd' WITH GRANT OPTION; 
    mysql> flush privileges;

使用homebrew安装mysql及遇到的问题

    brew install mysql
    unset TMPDIR
    bash mysql_install_db --verbose --user=root
    --basedir="$(brew --prefix mysql)"--datadir=/usr/local/var/mysql --tmpdir=/tmp
    bash mysql.server start