// 启动MySQL

[root@wode006 tools]# systemctl start mysqld

// 运行安全设置

[root@wode006 ~]# mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL

SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MySQL to secure it, we'll need the current

password for the root user.  If you've just installed MySQL, and

you haven't set the root password yet, the password will be blank,

so you should just press enter here.

Enter current password for root (enter for none):

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

Enter current password for root (enter for none):

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

Enter current password for root (enter for none):

OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MySQL

root user without the proper authorisation.

Set root password? [Y/n] Y

New password:

Re-enter new password:

Password updated successfully!

Reloading privilege tables..

... Success!

By default, a MySQL installation has an anonymous user, allowing anyone

to log into MySQL without having to have a user account created for

them.  This is intended only for testing, and to make the installation

go a bit smoother.  You should remove them before moving into a

production environment.

Remove anonymous users? [Y/n] Y

... Success!

Normally, root should only be allowed to connect from 'localhost'.  This

ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] n

... skipping.

By default, MySQL comes with a database named 'test' that anyone can

access.  This is also intended only for testing, and should be removed

before moving into a production environment.

Remove test database and access to it? [Y/n] Y

- Dropping test database...

ERROR 1008 (HY000) at line 1: Can't drop database 'test'; database doesn't exist

... Failed!  Not critical, keep moving...

- Removing privileges on test database...

... Success!

Reloading the privilege tables will ensure that all changes made so far

will take effect immediately.

Reload privilege tables now? [Y/n] Y

... Success!

All done!  If you've completed all of the above steps, your MySQL

installation should now be secure.

Thanks for using MySQL!

Cleaning up...

[root@wode006 ~]#

// 连接mysql

[root@wode006 ~]# mysql -u root -p

Enter password:

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 14

Server version: 5.6.25 MySQL Community Server (GPL)

Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

// 查看用户表

mysql> select user,host,password from mysql.user;

+------+-----------+-------------------------------------------+

| user | host      | password                                  |

+------+-----------+-------------------------------------------+

| root | localhost | * |

| root | wode006   | * |

| root | 127.0.0.1 | * |

| root | ::1       | * |

+------+-----------+-------------------------------------------+

4 rows in set (0.00 sec)

mysql>

// 设置远程访问

mysql> GRANT ALL ON *.* TO admin@'%' IDENTIFIED BY '123123' WITH GRANT OPTION;

Query OK, 0 rows affected (0.00 sec)

mysql> FLUSH PRIVILEGES;

Query OK, 0 rows affected (0.00 sec)

mysql>

// 再次查看用户表

mysql> select user,host,password from mysql.user;

+-------+-----------+-------------------------------------------+

| user  | host      | password                                  |

+-------+-----------+-------------------------------------------+

| root  | localhost | * |

| root  | wode006   | * |

| root  | 127.0.0.1 | * |

| root  | ::1       | * |

| admin | %         | * |

+-------+-----------+-------------------------------------------+

5 rows in set (0.00 sec)

mysql>

转载于:https://blog.51cto.com/huangchao/1670744

【MySQL】设置MySQL密码相关推荐

  1. mysql 密码 特殊符号_MySQL数据库之mysql设置复杂密码中含$特殊符号导致无法命令行登录...

    本文主要向大家介绍了MySQL数据库之mysql设置复杂密码中含$特殊符号导致无法命令行登录 ,通过具体的内容向大家展现,希望对大家学习MySQL数据库有所帮助. 安全考虑 在设置MYSQL 密码时候 ...

  2. Mysql设置初始化密码和修改密码

     转自:Mysql设置初始化密码和修改密码 刚开始创建mysql的时候,一般需要修改密码:而且,本人碰到过在几台服务器上面操作,忘记了其中一台的root密码(用户密码记得,root特别久没用了), ...

  3. MySQL设置简单密码

    有些小伙伴在设置MySQL的密码时,会提示Your password does not satisfy the current policy requirements,这是由于MySQL的安全策略导致 ...

  4. mysql 设置root密码

    mysql无root密码,设置root密码 mysql -uroot -p net stop mysql net start mysql 1. 找到mysql目录下my.ini并打开修改 在[mysq ...

  5. mysql设置用户密码的方法_mysql设置用户密码的几种方法

    本节我们讨论如何设置mysql用户密码: 首先我们应该知道Mysql数据库中的口令存储必须用password()函数加密它.因为在user表中是以加密形式存储口令,而不是作为纯文本.如果你没有加密,直 ...

  6. linux设置mysql root密码_Linux 上安装 Mysql 设置root密码问题

    Ubuntu 18.10.1 Mysql 5.7.26-0 安装mysql apt-get install mysql-server 安装完可以直接使用,但是新版本在安装过程中没有提示设置root用户 ...

  7. mysql设置初始密码(linux)

    1.先进入root权限: (1)如果没有设置密码先设置密码: sudo passwd root ---输入密码并确认 (2)然后进入root: su  root 2.然后直接进入mysql(刚下完默认 ...

  8. mysql安装设置mysql字符集utf8及修改密码

    MySQL的下载,建议下载MySQL的解压缩版本 MySQL官网下载推荐别下最新版本的原因是因为很多之前用的jar包和工具类不兼容最新版本的 可以下5.多的和六点多的 这样的压缩包解压再配置就行了 安 ...

  9. mysql 策略_MySQL 密码策略

    MySQL密码策略 MySQL 初始化时,使用临时密码,修改自定义密码时,由于自定义密码比较简单,就出现了不符合密码策略的问题. 密码策略问题异常信息: ERROR 1819 (HY000): You ...

  10. mysql配置文件改密码_mysql8.0 安装教程(自定义配置文件,密码方式已修改)

    下载zip安装包: MySQL8.0 For Windows zip包下载地址:https://dev.mysql.com/downloads/file/?id=476233,进入页面后可以不登录.后 ...

最新文章

  1. 论文LaTeX、项目README:无脑套用格式、开源模板最高10万赞
  2. jQuery设置样式 css
  3. 复习最基础的linux 之 创建用户及修改用户组
  4. 红帽收购混合云管理提供商NooBaa,混合云爆发节点临近!
  5. python语言函数库_Python 的标准库,从0到1学Python
  6. 十七UML核心视图动态视图之时序图
  7. 把对方陷入困境中(博弈论的诡计)
  8. linux python 环境 png,在mint-15 linux上显示python的.png图像
  9. yolov5搭建环境_YOLOv5从入门到部署之:训练私有数据并修改模型
  10. c语言的循环代码大全,循环 (C语言代码)
  11. VmPlayer上设置主机和windows虚拟机文件夹共享
  12. 前端promise、async重点总结
  13. 华为双前置摄像头_华为P40系列的前置双摄像头到底隐藏了什么?我们一起来看看...
  14. 五星大饭店韩文插曲-请不要离我而去MV
  15. 闭环系统零、极点位置对时间响应性能指标的影响
  16. BigDecimal舍入模式(Rounding Modes)
  17. 全国计算机普通话考试,全国普通话考试内容
  18. 系统类毕业设计思路以及各种遇到问题的解决办法
  19. NLP创业破局,如何摘取更高处的果实
  20. 鸿蒙os适配平板,华为新平板搭载高通4G芯片,鸿蒙OS已适配完成,友商随时可用...

热门文章

  1. 穿越五年的时空,重回三元湖畔
  2. 闯荡北京卖枣的临县人:同有一个“红枣美梦”(2张)
  3. Zookeeper系列五:Master选举、ZK高级特性:基本模型
  4. 关于JavaScript(脚本语言)
  5. Angular 4 辅助路由
  6. springmvc学习笔记--Interceptor机制和实践
  7. C语言数组作为传入参数
  8. android视频播放指定位置,android – 如何在某个特定位置的视图中查看视频?
  9. asp.net 中GridView控件实现全选及反选的功能
  10. HNCU1101:马的移动---BFS