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/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Change redhat root passwordRedhat
- Do we need HACMP?ACM
- How to Reset the MySQL Root PasswordMySql
- E. We Need More Bosses
- Oracle WebLogic Default Password & Change PasswordOracleWeb
- Post Installation for Databases Created after Installation of 10.2.0.4.4Database
- ITaCS Change Password web partWeb
- lsnrctl中,SET PASSWORD和CHANGE_PASSWORD命令
- Give root password for maintenanceAINaN
- No need to set a listener password in ORACLE 10GOracle 10g
- Useless SAP PA certificate, do we still need to get it?
- mysql 1045, "Access denied for user 'root'@'localhost' (using password: NO)"MySqllocalhost
- MYSQL解決error: 'Access denied for user 'root'@'localhost' (using password:MySqlErrorlocalhost
- 【MySQL】---1045-Access denied for user 'root'@'localhost'(using password :YES)MySqllocalhost
- How to Clean Up After a Failed Oracle Clusterware (CRS) InstallationAIOracle
- Hacked VisualSVN Server by PHP to allow user change passwordServerPHP
- How to change the APPS db password in Oracle EBSAPPOracle
- MySQL系列:Docker安裝 MySQL提示錯誤:Access denied for user'root'@'localhost' (using password:yes)MySqlDockerlocalhost
- Access denied for user 'root'@'localhost' (using password: NO)localhost
- Mysql MAC installationMySqlMac
- Output Type SPER Delete Inbound Delivery After We Reverse PGI for STO' outbounddelete
- No OAM Application Manager Link in R12 after a fresh installationAPP
- clean all Oracle 10gR2 CRS after a failed CRS installationOracle 10gAI
- 老外也大喊We need English?這國產遊戲秀得我頭皮發麻遊戲
- #1045 - Access denied for user 'root'@'localhost' (using password: NO)localhost
- 解決Mysql:ERROR 1045 (28000):Access denied for user ‘root‘@‘localhost‘ (using password: NO)的方法MySqlErrorlocalhost
- How to change the password for win2003 via remote desktopREM
- mysql change buffer小結MySql
- MYSQL TABLE CHANGE STORAGE ENGINEMySql
- MySQL 8.0.13 密碼問題 ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)MySql密碼Errorlocalhost
- root.sh Fails on the First Node for 11gR2 GI InstallationAI
- Mysql_secure_installation詳解MySql
- mac os x 安裝mysql遇到 Access denied for user ‘root‘@‘localhost‘ (using password: YES)的解決方法MacMySqllocalhost
- 使用root 切換普通使用者提示:[sudo] password for oracle:Oracle
- ERROR 1045: Access denied for user: 'root@localhost' (Using password: NO)Errorlocalhost
- 11.2.0.1 Grid Infrastructure Installation Failed at .... While Running root.shASTStructAIWhile
- Your password has expired. To log in you must change it using a client that supports expired passworclient
- linux安裝MySQL出現ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)LinuxMySqlErrorlocalhost