Mysql添加新用户以及用户权限

添加新的用户

  1. 允许本地 IP访问localhost的Mysql数据库
mysql> create user '你要新建的用户名'@'你的ip(本机为localhost)' identified by '你的密码';

Query OK, 0 rows affected (0.06 sec)
  1. 允许外网IP访问数据库editest,本命令包含上面的命令,是所有的IP都可以访问该数据库
mysql> create user '你要新建的用户名'@'%' identified by '你的密码';

Query OK, 0 rows affected (0.00 sec)
  1. 用户创建完成后,刷新授权
mysql> flush privileges;

Query OK, 0 rows affected (0.00 sec)
  1. 创建一个新的数据库,并使用show databases命令查

编辑my.con配置文件:

vim /etc/my.cnf

修改以下内容:

\# For advice on how to change settings please see

\# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html

[client]

default-character-set=utf8mb4

[mysql]

default-character-set=utf8mb4

[mysqld]

character-set-server=utf8mb4

\# Remove leading # and set to the amount of RAM for the most important data

\# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.

\# innodb_buffer_pool_size = 128M

\# Remove leading # to turn on a very important data integrity option: logging

\# changes to the binary log between backups.

\# log_bin


\# The server defaults are faster for transactions and fast SELECTs.

\# Adjust sizes as needed, experiment to find the optimal values.

\# join_buffer_size = 128M

\# sort_buffer_size = 2M

\# read_rnd_buffer_size = 2M

datadir=/var/lib/mysql

socket=/var/lib/mysql/mysql.sock

\# Disabling symbolic-links is recommended to prevent assorted security risks

symbolic-links=0

log-error=/var/log/mysqld.log

pid-file=/var/run/mysqld/mysqld.pid
  1. 保存退出,重新启动mysql:

    service mysqld restart



   转载规则


《Mysql添加新用户以及用户权限》 旋律JOJO哒 采用 知识共享署名 4.0 国际许可协议 进行许可。
  目录