柳暗花明笔记

    Adding new users to MySQL Databases

    所属分类:[ linux&mysql ] 猫哲学家 发表于:2012-08-10 22:32 浏览:430

    # Connect to the local database server as user root # You will be prompted for a password. # mysql -h localhost  -u root -p # # Now we see the 'mysql>' prompt and we can run # the following to create a new database for Paul. # mysql> create database pauldb; Query OK, 1 row affected (0.00 sec) # # Now we create the user paul and give him full  # permissions on the new database mysql> grant CREATE,INSERT,DELETE,UPDATE,SELECT on pauldb.* to paul@localhost; Query OK, 0 rows affected (0.00 sec) # # Next we set a password for this new user # mysql> set password for paul = password('mysecretpassword'); Query OK, 0 rows affected (0.00 sec) # # Cleanup and ext mysql> flush privileges; mysql> exit; 



    [root@localhost ~]# mysql -u root -p
    Enter password:

    mysql> CREATE DATABASE databasename;
    Query OK, 1 row affected (0.00 sec)

    mysql> GRANT ALL PRIVILEGES ON databasename.* TO "username"@"%" IDENTIFIED BY "password";

    *注:若取消远程访问该库权限:revoke all privileges on databasesname.* from "username"@"%";

    另若是取消删除该用户远程连接:先开mysql库 use mysql; -->然后 delete from user where user="username" and host="%";

    mysql> FLUSH PRIVILEGES;   (刷新权限生效,这一步一定一定要执行)

     

    【更改mysql用户名的密码】

    mysql> use mysql;
    mysql> update user set password = password("gueqi201158") where user = "gueqi_shop";
    mysql> flush privileges;

     

    【允许/禁止root远程登录】

    mysql> use mysql;
    mysql> delete from user where user='root' and host='%';  禁止root远程登录
    GRANT ALL PRIVILEGES ON *.* TO "root"@"%" IDENTIFIED BY "password"; 允许root远程登录
    FLUSH PRIVILEGES;   (刷新权限生效,这一步一定一定要执行)

    标签: mysql 
    上一编文章 is not allowed to connect to this MySQL server 下一编文章 10 Ways to Automatically & Manually Backup MySQL Database
    最近文章
    发表评论