当前位置:网站首页>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
边栏推荐
- Remote - actual combat
- DIY personal server (DIY storage server)
- Go language go language built-in container
- 文件操作详解
- Chapter VI modified specification (SPEC) class
- Formatdatetime explanation [easy to understand]
- Online random coin tossing positive and negative statistical tool
- Remote—实战
- 从底层结构开始学习FPGA(16)----PLL/MMCM IP的定制与测试
- 103. (cesium chapter) cesium honeycomb diagram (square)
猜你喜欢
![[onnx] export pytorch model to onnx format: support multi parameter and dynamic input](/img/bd/e9a1d3a2c9343b75dbae5c7e18a87b.png)
[onnx] export pytorch model to onnx format: support multi parameter and dynamic input
![Vulnhub | dc: 6 | [actual combat]](/img/7e/de7d5b56724bde5db2bb8338c35aa8.png)
Vulnhub | dc: 6 | [actual combat]

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

Leetcode-6131: the shortest dice sequence impossible to get

Working principle of radar water level gauge and precautions for installation and maintenance

Remote - basic principle introduction

火山引擎项亮:机器学习与智能推荐平台多云部署解决方案正式发布

Recommended books | essentials of industrial digital transformation: methods and Practice

Illustration leetcode - 3. longest substring without repeated characters (difficulty: medium)
![[today in history] July 3: ergonomic standards act; The birth of pioneers in the field of consumer electronics; Ubisoft releases uplay](/img/18/b06e2e5a2f76dc2da1c2374b8424b3.png)
[today in history] July 3: ergonomic standards act; The birth of pioneers in the field of consumer electronics; Ubisoft releases uplay
随机推荐
毕业从事弱电3个月,我为什么会选择转行网络工程师
[today in history] July 4: the first e-book came out; The inventor of magnetic stripe card was born; Palm computer pioneer was born
Kubernetes进阶部分学习笔记
[advanced mathematics] [3] Application of differential mean value theorem and derivative
Principle analysis of bootloader
Clickhouse notes 02 -- installation test clickvisual
How to realize reliable transmission with UDP?
TGA file format (waveform sound file format)
Working principle of radar water level gauge and precautions for installation and maintenance
Compilation and operation of program
Formatdatetime explanation [easy to understand]
Use of C log4net: add file name and line number to the output log content; Repackaged class output file name and line number
Has baozi ever played in the multi merchant system?
Detailed explanation of document operation
Google guava is just a brother. What is the real king of caching? (glory Collection Edition)
[today in history] July 17: Softbank acquired arm; The first email interruption; Wikimedia International Conference
Leetcode-114: expand binary tree into linked list
Is QQ 32-bit or 64 bit software (where to see whether the computer is 32-bit or 64 bit)
雷达水位计的工作原理及安装维护注意事项
Solution to oom exceptions caused by improper use of multithreading in production environment (supreme Collection Edition)