当前位置:网站首页>When MySQL resets the root password and modifies the password, an error occurs. The password field does not exist
When MySQL resets the root password and modifies the password, an error occurs. The password field does not exist
2022-07-25 20:41:00 【Full stack programmer webmaster】
Hello everyone , I meet you again , I'm the king of the whole stack .
One .MySQL Reset root password
close MySQL The server :
service mysql stopEntry directory ,
cd /usr/local/mysql/bin Start in safe mode MySQL./mysqld_safe --skip-grant-tables &Be careful : Maybe your system doesn't safe_mysqld Program (Windows or Ubuntu operating system ) , have access to mysqld: mysqld --skip-grant-tables &
After starting , root User logs in with blank password mysql:
# mysql -u root
mysql> update mysql.user set password=PASSWORD('123456') where User='root'; # Change Password
mysql> flush privileges; # Refresh the permissions
mysql> quit start-up MySQL:
service mysql startTwo .MySQL5.7 Appears when the password is changed ERROR 1054 (42S22): Unknown column ‘password’ in ‘field list’
Error reported after execution ERROR 1054(42S22) Unknown column ‘password’ in ‘field list’
The reason for the mistake is 5.7 Version mysql There is no password This field ,password Field changed to authentication_string
So please use the command :
update mysql.user set authentication_string=PASSWORD('root') where User='root';thus , modify root The password succeeded .
3、 ... and . An error occurs when creating a user , operation failed : Because this user currently exists , Or you do not have refresh permission after deleting users .
ERROR 1396 (HY000): Operation CREATE USER failed for 'code'@'localhost'Four .MySQL Creating users and authorizations
(1) Create user
command :
CREATE USER 'username'@'host' IDENTIFIED BY 'password';explain :
- username: The user name you will create
- host: Specifies on which host the user can log in , If available to local users localhost, If you want the user to be able to Login from any remote host , You can use wildcards
% - password: The login password of the user , The password can be null , If it is empty, the user can log in to the server without a password
Example :
CREATE USER 'dog'@'localhost' IDENTIFIED BY '123456';
CREATE USER 'pig'@'192.168.1.101_' IDENDIFIED BY '123456';
CREATE USER 'pig'@'%' IDENTIFIED BY '123456';
CREATE USER 'pig'@'%' IDENTIFIED BY '';
CREATE USER 'pig'@'%';(2) to grant authorization :
command :
GRANT privileges ON databasename.tablename TO 'username'@'host'explain :
- privileges: User action permissions , Such as
SELECT,INSERT,UPDATEetc. , Use if you want to grant permissionsALL - databasename: Database name
- tablename: Table name , Available if you want to grant the user access to all databases and tables
*Express , Such as*.*
Example :
GRANT SELECT, INSERT ON test.user TO 'pig'@'%';
GRANT ALL ON *.* TO 'pig'@'%';Be careful :
Users authorized by the above command cannot authorize other users , If you want the user to be authorized , Use the following command :
GRANT privileges ON databasename.tablename TO 'username'@'host' WITH GRANT OPTION;(3). Set and change user passwords
command :
SET PASSWORD FOR 'username'@'host' = PASSWORD('newpassword');If it is the current login user :
SET PASSWORD = PASSWORD("newpassword");Example :
SET PASSWORD FOR 'pig'@'%' = PASSWORD("123456");(4). Revoke user privileges
command :
REVOKE privilege ON databasename.tablename FROM 'username'@'host';explain :
privilege, databasename, tablename: Same authorization part
Example :
REVOKE SELECT ON *.* FROM 'pig'@'%';Be careful :
Let's say you're giving it to the user 'pig'@'%' That's what happens when you delegate ( Or similar ):GRANT SELECT ON test.user TO 'pig'@'%', In the use REVOKE SELECT ON *.* FROM 'pig'@'%'; The command does not undo the user pair test In the database user Tabular SELECT operation . contrary , If authorized to use is GRANT SELECT ON *.* TO 'pig'@'%'; be REVOKE SELECT ON test.user FROM 'pig'@'%'; The command also cannot undo the user pair test In the database user Tabular Select jurisdiction .
Specific information can be ordered SHOW GRANTS FOR 'pig'@'%'; see .
(5). Delete user
command :
DROP USER 'username'@'host';Reference resources :https://www.jianshu.com/p/d7b9c468f20d
Publisher : Full stack programmer stack length , Reprint please indicate the source :https://javaforall.cn/111553.html Link to the original text :https://javaforall.cn
边栏推荐
- What is cluster analysis? Categories of cluster analysis methods [easy to understand]
- Leetcode-6130: designing digital container systems
- 智能电子界桩自然保护区远程监控解决方案
- Network protocol: TCP part2
- If the order is not paid for 30 minutes, it will be automatically cancelled. How to achieve this? (Collection Edition)
- Leetcode-6126: designing a food scoring system
- Embedded development: embedded foundation -- threads and tasks
- 每条你收藏的资讯背后,都离不开TA
- Unity vs -- the default debugging in VS is to start rather than attach to unity debugging
- leetcode-146:LRU 缓存
猜你喜欢

leetcode-6130:设计数字容器系统

Detailed explanation of document operation
![[today in history] June 28: musk was born; Microsoft launched office 365; The inventor of Chua's circuit was born](/img/bf/09ccf36caec099098a22f0e8b670bd.png)
[today in history] June 28: musk was born; Microsoft launched office 365; The inventor of Chua's circuit was born

ROS_ Rqt toolbox

Step num problem

Why did I choose to become a network engineer after graduating from weak current for 3 months

Online XML to JSON tool

KEGG通路的从属/注释信息如何获取
![[paper reading] unpaired image to image translation using cycle consistent advantageous networks](/img/73/69651dd8ecfdddd1cae13a1d223d51.png)
[paper reading] unpaired image to image translation using cycle consistent advantageous networks
![MySQL date [plus sign / +] condition filtering problem](/img/86/aed048e27b3e0b0baa919204bc067c.png)
MySQL date [plus sign / +] condition filtering problem
随机推荐
leetcode-6130:设计数字容器系统
Google guava is just a brother. What is the real king of caching? (glory Collection Edition)
[today in history] June 28: musk was born; Microsoft launched office 365; The inventor of Chua's circuit was born
Leetcode-6130: designing digital container systems
[matlab] download originality documents based on oil monkey script and MATLAB
[tensorrt] dynamic batch reasoning
[advanced mathematics] [8] differential equation
Vulnhub | dc: 6 | [actual combat]
MySQL inserts three tables with different values. The association condition is the primary foreign key. How about the syntax of the insertion statement?
7.23
LeetCode通关:哈希表六连,这个还真有点简单
[today in history] July 19: the father of IMAP agreement was born; Project kotlin made a public appearance; New breakthroughs in CT imaging
SecureCRT garbled code solution [easy to understand]
test
JS scope and scope chain
Apache Mina framework "suggestions collection"
Recommended books | essentials of industrial digital transformation: methods and Practice
【ONNX】pytorch模型导出成ONNX格式:支持多参数与动态输入
Success factors of software R & D effectiveness measurement
Scan delete folder problems