MySQL8.0 配置笔记
2018-10-17 22:43
417 查看
版权声明:本系列文档版权归 Tinywan个人所有,未经授权,禁止任何方式转载和下载,侵权必究! https://blog.csdn.net/qq756684177/article/details/83120218
今天把数据库配置文件修改了,结果重启不了了
需要使用 mysqld --initialize 或 mysqld --initialize-insecure 命令来初始化数据库
1、mysqld --initialize-insecure可以不生成随机密码,设置数据库空密码。
2、安装Mysql时默认使用的是mysqld --initialize命令。这个命令也会生成一个随机密码。改密码保存在了Mysql的日志文件中
3、通过配置文件查看日志文件路径 /etc/mysql/mysql.conf.d/mysqld.cnf。打开该文件,可以看到mysql的datadir和log文件等的配置信息
# 日志文件路径 log-error = /var/log/mysql/error.log
4、打开log文件并搜索 password ,可以看到密码
5、登录数据库
使用找到的随机密码登录mysql,首次登录后,mysql要比必须修改默认密码,否则不能执行任何其他数据库操作,这样体现了不断增强的Mysql安全性。
这里会有几个问题
1、提示必须的修改密码
2、8.0修改密码命令
ALTER user 'root'@'localhost' IDENTIFIED BY 'Tinywan123456'
创建新用户
MySQL8.0取消了直接grant创建用户的语法,只能先create user再grant,因此创建root如下
mysql> use mysql Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed mysql> create user user001@'localhost' identified by '112233'; Query OK, 0 rows affected (0.01 sec) mysql> FLUSH PRIVILEGES; Query OK, 0 rows affected (0.00 sec) mysql> create user user002@'%' identified by '112233'; Query OK, 0 rows affected (0.01 sec) mysql> FLUSH PRIVILEGES; Query OK, 0 rows affected (0.00 sec)
测试user001远程登录
$ mysql -u user001 -p112233 -h 159.11.213.20 mysql: [Warning] Using a password on the command line interface can be insecure. Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 35 Server version: 8.0.12 MySQL Community Server - GPL Copyright (c) 2000, 2018, 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> show databases; +--------------------+ | Database | +--------------------+ | information_schema | +--------------------+ 1 row in set (0.00 sec) mysql>
Navicat Premium 远程连接不了
提示一下信息
如何解决:
1、先通过命令行进入mysql的root账户
mysql -h localhost -uroot -pTinywan123456
2、更改加密方式
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'password' PASSWORD EXPIRE NEVER; Query OK, 0 rows affected (0.10 sec)
3、修改密码
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password'; Query OK, 0 rows affected (0.35 sec)
4、清除缓存
mysql> FLUSH PRIVILEGES; Query OK, 0 rows affected (0.28 sec)
5、重新连接Navicat Premium 可以正常连接成功
参考:
1、https://www.geek-share.com/detail/2737453546.html
2、https://www.geek-share.com/detail/2605035263.html
阅读更多相关文章推荐
- MySQL8.0 配置笔记
- (一)windows系统Mysql安装与配置1---学习笔记
- nagios3.20安装配置笔记(带飞信短信报警,mssql和mysql监控)
- linux学习笔记29-mysql的配置
- Linux+Nginx+Apache+PHP+Mysql安装配置笔记
- LNMP= CentOS+Nginx+MySQL+PHP 安装配置及简易建站笔记(持续更新中)
- [笔记]MySQL 配置优化
- Windows下Apache + MySQL配置PHP环境笔记
- 【开发笔记】mysql-5.6.14-winx64免安装配置
- Mysql DBA 高级运维学习笔记-Mysql常见多实例配置方案及多实例安装
- (二)linux系统Mysql安装与配置2---学习笔记
- 我的linux笔记——配置jdk/tomcat/mysql
- Mysql DBA 高级运维学习笔记-heartbeat高可用软件的安装及配置
- Linux+Apache+PHP+MYSQL环境配置学习笔记
- 腾讯云 centos7.1 64位+mysql5.5配置笔记
- MySQL主从配置笔记
- Windows下Apache + MySQL配置PHP环境笔记
- 24、MySQL 8.0 5.1.2服务器配置默认值
- ubuntu学习笔记5_MySQL基础功能及配置