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


添加新的用户

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

Query OK, 0 rows affected (0.06 sec)```

2. 允许外网IP访问数据库editest,本命令包含上面的命令,是所有的IP都可以访问该数据库

```mysql
mysql> create user '你要新建的用户名'@'%' identified by '你的密码';

Query OK, 0 rows affected (0.00 sec)```


3. 用户创建完成后,刷新授权

```mysql
mysql> flush privileges;

Query OK, 0 rows affected (0.00 sec)```


4. 创建一个新的数据库,并使用show databases命令查

编辑my.con配置文件:


```shell
vim /etc/my.cnf```



修改以下内容:

```shell
\# 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```



5. 保存退出,重新启动mysql:

 service mysqld restart


```python

文章作者: 旋律JOJO哒
版权声明: 本博客所有文章除特別声明外,均采用 CC BY 4.0 许可协议。转载请注明来源 旋律JOJO哒 !
评论
  目录