Mysql 5.7 CentOS Access denied for user 'root'@'localhost'解決方式
在centOS上安裝完mysql, 登入MYSQL時遇到錯誤
[root@mysql-server Downloads]# mysql -u root
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
關鍵要用MYSQLD_OPTS="--skip-grant-tables"重新啟動mysql服務
[root@mysql-server Downloads]# systemctl stop mysqld
[root@mysql-server Downloads]# systemctl set-enviroment MYSQLD_OPTS="--skip-grant-tables"
Unknown operation 'set-enviroment'.
[root@mysql-server Downloads]# systemctl set-environment MYSQLD_OPTS="--skip-grant-tables"
[root@mysql-server Downloads]# systemctl start mysqld
[root@mysql-server Downloads]# myslq -u root
bash: myslq: command not found...
Similar command is: 'mysql'
[root@mysql-server Downloads]# mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.18 MySQL Community Server (GPL)
Copyright (c) 2000, 2017, 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 |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.06 sec)
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> update user set authentication_string=password('root') where user = 'root';
Query OK, 1 row affected, 1 warning (0.07 sec)
Rows matched: 1 Changed: 1 Warnings: 1
mysql> flush previleges;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'previleges' at line 1
mysql> flush priviledges;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'priviledges' at line 1
mysql> flush privileges;
Query OK, 0 rows affected (0.11 sec)
mysql> quit
Bye
[root@mysql-server Downloads]# systemctl stop mysqld
[root@mysql-server Downloads]# systemctl unset-environment MYSQLD_OPTS
[root@mysql-server Downloads]# systemctl start mysqld
[root@mysql-server Downloads]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.18
Copyright (c) 2000, 2017, 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>
參考:https://stackoverflow.com/questions/33510184/change-mysql-root-password-on-centos7
[root@mysql-server Downloads]# mysql -u root
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
關鍵要用MYSQLD_OPTS="--skip-grant-tables"重新啟動mysql服務
[root@mysql-server Downloads]# systemctl stop mysqld
[root@mysql-server Downloads]# systemctl set-enviroment MYSQLD_OPTS="--skip-grant-tables"
Unknown operation 'set-enviroment'.
[root@mysql-server Downloads]# systemctl set-environment MYSQLD_OPTS="--skip-grant-tables"
[root@mysql-server Downloads]# systemctl start mysqld
[root@mysql-server Downloads]# myslq -u root
bash: myslq: command not found...
Similar command is: 'mysql'
[root@mysql-server Downloads]# mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.18 MySQL Community Server (GPL)
Copyright (c) 2000, 2017, 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 |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.06 sec)
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> update user set authentication_string=password('root') where user = 'root';
Query OK, 1 row affected, 1 warning (0.07 sec)
Rows matched: 1 Changed: 1 Warnings: 1
mysql> flush previleges;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'previleges' at line 1
mysql> flush priviledges;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'priviledges' at line 1
mysql> flush privileges;
Query OK, 0 rows affected (0.11 sec)
mysql> quit
Bye
[root@mysql-server Downloads]# systemctl stop mysqld
[root@mysql-server Downloads]# systemctl unset-environment MYSQLD_OPTS
[root@mysql-server Downloads]# systemctl start mysqld
[root@mysql-server Downloads]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.18
Copyright (c) 2000, 2017, 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>
參考:https://stackoverflow.com/questions/33510184/change-mysql-root-password-on-centos7
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/8520577/viewspace-2140841/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- ubuntu mysql Access denied for user root@localhostUbuntuMySqllocalhost
- Access denied for user ‘root‘@‘localhost‘問題的解決localhost
- mysql 1045, "Access denied for user 'root'@'localhost' (using password: NO)"MySqllocalhost
- 解決Mysql:ERROR 1045 (28000):Access denied for user ‘root‘@‘localhost‘ (using password: NO)的方法MySqlErrorlocalhost
- Ubuntu18.04:mysql:ERROR 1698 (28000): Access denied for user ‘root‘@‘localhost‘UbuntuMySqlErrorlocalhost
- 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
- 啟動報錯: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
- MySQL系列:Docker安裝 MySQL提示錯誤:Access denied for user'root'@'localhost' (using password:yes)MySqlDockerlocalhost
- MySQL 8.0.13 密碼問題 ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)MySql密碼Errorlocalhost
- vue專案中連線MySQL時,報錯ER_ACCESS_DENIED_ERROR: Access denied for user 'root'@'localhost' (using password:YES)VueMySqlErrorlocalhost
- MySQL使用普通使用者訪問返回ERROR 1698 (28000): Access denied for user 'root'@'localhost'MySqlErrorlocalhost
- Linux錯誤 ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)LinuxErrorlocalhost
- SpringBoot中yml配置java.sql.SQLException: Access denied for user ‘root‘@‘localhost‘ (using password: NOSpring BootJavaSQLExceptionlocalhost
- SQLSTATE[HY000] [1045] Access denied for user ‘root‘@‘localhost‘ (using password: YES)”錯誤的隱藏解決辦法SQLlocalhost
- 【本人親測 已解決】044 - Access denied for user ‘root‘@‘%‘ to database ‘資料庫名稱‘Database資料庫
- Navicat遠端連線MySQL 提示1045 - Access denied for user 'root'@'223.74.158.192'(using password:YES)MySql
- Permission denied:user=xxx,access=WRITE,inode=xxx
- Access denied for user 'default'@'%' to database 'shop'報錯Database
- laravel mysql批量提交報Access denied 錯誤LaravelMySql
- mysql 5.7忘記root密碼MySql密碼
- Caused by: java.sql.SQLException: Access denied for user 'dell-pc'@'xxxxx' (using password: YES)JavaSQLException
- hive建立分割槽表報錯AccessControlException Permission denied: user=NONE, access=WRITE, inodeHiveExceptionNone
- Windows git remote: HTTP Basic: Access denied 錯誤解決辦法WindowsGitREMHTTP
- 解決centos 刪除資料夾 permission deniedCentOS
- MYSQL5.7 ROOT密碼修改教程MySql密碼
- 在CentOS7上安裝MySQL5.7-YUM源方式CentOSMySql
- Linux下Centos7以rpm方式離線安裝MySQL5.7教程以及部分報錯解決方案LinuxCentOSMySql
- NFS掛載時出現”access denied by server while mounting”的解決方法NFSServerWhile
- mysql5.7重置root密碼MySql密碼
- Ubuntu MySQL5.7設定root密碼UbuntuMySql密碼
- CentOS 7 安裝 MySQL 5.7CentOSMySql
- CentOS 7 - 安裝MySQL 5.7CentOSMySql
- centos安裝mysql5.7CentOSMySql
- mybatis進行資料庫建表 CREATE command denied to user 'root'@'127.0.0.1' for table 問題MyBatis資料庫127.0.0.1
- nginx中報Access denied.Nginx
- 教你怎麼解決MySQL 5.7及8.0版本資料庫的root密碼遺忘MySql資料庫密碼