how to use mysql on mac

1.开启远程连接(非mysqld -h localhost -u *登录)
  1)改表法
     use mysql;
     update user set host = '%' where user = 'root';
     select host, user from user where user = 'root';
  2)授权法
     用户root使用123456密码从任何主机连接到mysql服务器:
           GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
           FLUSH PRIVILEGES;
     用户root使用123456密码从ip为192.168.1.128的主机连接到mysql服务器:
           GRANT ALL PRIVILEGES ON *.* TO 'root'@'192.168.1.128' IDENTIFIED BY '123456' WITH GRANT OPTION;
           FLUSH PRIVILEGES;
     用户root使用123456密码从ip为192.168.1.128的主机连接到mysql服务器的test数据库:
           GRANT ALL PRIVILEGES ON test.* TO 'root'@'192.168.1.128' IDENTIFIED BY '123456' WITH GRANT OPTION;
           FLUSH PRIVILEGES;
2.
  mysql启动:/usr/local/mysql/bin/mysqld_safe --user=Eric & # sudo /usr/local/mysql/bin/mysqld_safe --console
  mysql停止:sudo /usr/local/mysql/bin/mysqld_safe stop # sudo /usr/local/mysql/bin/mysqladmin -u root shutdown
  更改mysql root账户密码:/usr/local/mysql/bin/mysqladmin -u root 新密码
    [/usr/local/mysql/bin/mysqld -h localhost -u root -proot]创建用户|分配权限:
     grant all privileges on *.* to 'user'@'localhost' with grant option
     grant all privileges on *.* to 'user'@'localhost' identified by '123456′;
  # 授权test用户拥有testdb数据库的所有权限。
     grant all privileges on testdb.* to test@localhost identified by '123456';
     grant select,update on testdb.* to test@localhost identified by '123456';
     flush privileges;
  新建用户:
     insert into mysql.user(Host,User,Password) values("localhost","test",password("123456"));
     flush privileges;
  删除用户:
     DELETE FROM user WHERE User="test" and Host="localhost";
     flush privileges;
  修改指定用户密码:
     update mysql.user set password=password('新密码') where User="test" and Host="localhost";
     flush privileges;
3.mac创建组及分配
    sudo dscl . -list /groups GroupMembership
    sudo dscl . -list /Groups PrimaryGroupID
    sudo dscl . create /Groups/mysql PrimaryGroupID 403
    sudo dscl . -append /Groups/mysql GroupMembership Eric
  /usr/local/mysql/my.cnf
http://www.ntu.edu.sg/home/ehchua/programming/sql/MySQL_HowTo.html

转载于:https://www.cnblogs.com/wen12128/p/4224472.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值