After mysql installation, we need to change the password of root as below
1. initial mysql like below, With the --initialize-insecure option, no root password is generated.
[LAB] root@jptkytcdh01vl /etc/init.d # /usr/sbin/mysqld --initialize-insecure --user=mysql --datadir=/var/lib/mysql
2018-08-03T01:26:56.052349Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-08-03T01:26:56.054339Z 0 [ERROR] --initialize specified but the data directory has files in it. Aborting.
2018-08-03T01:26:56.054378Z 0 [ERROR] Aborting
2. got error as above, need to move existing datadir first.
mv /var/lib/mysql /var/lib/mysql_20180803
[LAB] root@jptkytcdh01vl /etc/init.d # /usr/sbin/mysqld --initialize-insecure --user=mysql --datadir=/var/lib/mysql
[LAB] root@jptkytcdh01vl /etc/init.d # service mysqld start
Starting mysqld: [ OK ]
3. then login and reset the password.
[LAB] root@jptkytcdh01vl /etc/init.d # mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.23 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>
mysql> alter user 'root'@'localhost' identified by 'root';
Query OK, 0 rows affected (0.00 sec)
Doc.
https://dev.mysql.com/doc/refman/5.7/en/data-directory-initialization-mysqld.html
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/10973950/viewspace-2169048/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- E. We Need More Bosses
- mysql 1045, "Access denied for user 'root'@'localhost' (using password: NO)"MySqllocalhost
- Useless SAP PA certificate, do we still need to get it?
- FreeBSD on Raspberry PI root, freebsd account password
- MySQL系列:Docker安裝 MySQL提示錯誤:Access denied for user'root'@'localhost' (using password:yes)MySqlDockerlocalhost
- 解決Mysql:ERROR 1045 (28000):Access denied for user ‘root‘@‘localhost‘ (using password: NO)的方法MySqlErrorlocalhost
- MySQL 8.0.13 密碼問題 ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)MySql密碼Errorlocalhost
- Navicat遠端連線MySQL 提示1045 - Access denied for user 'root'@'223.74.158.192'(using password:YES)MySql
- Output Type SPER Delete Inbound Delivery After We Reverse PGI for STO' outbounddelete
- root.sh Fails on the First Node for 11gR2 GI InstallationAI
- ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password:YES)Errorlocalhost
- mac os x 安裝mysql遇到 Access denied for user ‘root‘@‘localhost‘ (using password: YES)的解決方法MacMySqllocalhost
- mysql change buffer小結MySql
- 域滲透——Dump Clear-Text Password after KB2871997 installed
- 啟動報錯:Access denied for user 'root'@'localhost' (using password:YES)localhost
- 報錯”ERROR 1045 (28000): Access denied for user ‘root’@’localhost’ (using password: NO)”Errorlocalhost
- java.sql.SQLException: Access denied for user ‘root‘@‘localhost‘ (using password: YES)JavaSQLExceptionlocalhost
- 老外也大喊We need English?這國產遊戲秀得我頭皮發麻遊戲
- 十五年後,老外仍在為任天堂這款另類RPG高呼“We Need English!”
- Linux錯誤 ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)LinuxErrorlocalhost
- vue專案中連線MySQL時,報錯ER_ACCESS_DENIED_ERROR: Access denied for user 'root'@'localhost' (using password:YES)VueMySqlErrorlocalhost
- MySQL 重置Root密碼MySql密碼
- IOMESH Installation
- SpringBoot中yml配置java.sql.SQLException: Access denied for user ‘root‘@‘localhost‘ (using password: NOSpring BootJavaSQLExceptionlocalhost
- mysql alter modify 和 change的區別MySql
- MySQL 8.0 重置 root 密碼MySql密碼
- 技術分享 | MySQL:change buffer 何時生效MySql
- MySQL學習之change buffer 和 redo logMySql
- 2.3.3.2 Application InstallationAPP
- mysql 5.7忘記root密碼MySql密碼
- 修改Mysql root密碼的方法MySql密碼
- 細說 MySQL 之 MEM_ROOTMySql
- mysql的唯一索引不會利用change bufferMySql索引
- A Tomcat 8.0 installation is expectedTomcat
- mysql 8.0.11 以上版本修改root密碼MySql密碼
- ubuntu mysql Access denied for user root@localhostUbuntuMySqllocalhost
- MySQL的Root使用者密碼MySql密碼
- mysql忘了root密碼怎麼辦MySql密碼