mysql 新建用户并赋予远程访问权限


不多说直接上代码

[root@demo /]# mysql -u root -p  #登录服务器数据库

Enter password:123xxx

#1.创建一个新用户 testuser 密码为 testuserpass
CREATE USER 'testuser'@'localhost' IDENTIFIED BY 'testuserpass';
#2.创建数据库testDB create database testDB;
#3.执行命令为testuser用户添加使用testDB权限 grant all privileges on testDB.
* to testuser@localhost identified by 'testuserpass';
#4.执行命令,为testuser用户添加远程访问权限 GRANT ALL PRIVILEGES ON testDB.
* TO 'testuser'@'%' IDENTIFIED BY 'testuserpass' WITH GRANT OPTION;

#5.刷新权限表
flush privileges;

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM