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.htmlhtml

相關文章
相關標籤/搜索