


How to change mysql database password under linux? How to change database password in Linux
Oct 22, 2018 pm 05:23 PMThe content of this article is to introduce how to change the mysql database password under Linux? How to change database password in Linux. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.
How to modify Mysql under Linux (root password and modify root login permissions
The modified users are listed as root.
1. Know the root password of the original myql database;
①: Enter mysqladmin -u root -p password "new password" at the terminal command line and press Enter, Enter password: /* Enter the original old password*/
②: Log in to the mysql system to modify, mysql -uroot -p Enter password: /* Enter the original password */
mysql>use mysql; mysql> update user set password=password(“新密碼”) where user=‘root’; /* 密碼注意大小寫 */ mysql> flush privileges; mysql> exit; service mysqld/mysql statusservice mysqld/mysql restart/start
Then use the new password you just entered to log in.
2. I don’t know the original myql root password;
First of all, you must have root permissions on the operating system. If you don’t even have root permissions on the system, consider rooting the system first and then take the following steps. . Similar to logging in to the system in safe mode.
You need to stop the mysql service first. There are two situations. One can use service mysqld stop,
The other is /etc/init.d /mysqld stop
When prompted that mysql has stopped, proceed to the next step Shutting down MySQL. SUCCESS!
Enter on the terminal command line
mysqld_safe --skip-grant-tables & /* 登錄mysql系統(tǒng) */
Enter mysql to log in to the mysql system
mysql> use mysql; mysql> UPDATE user SET password=password(“新密碼”) WHERE user=‘root’; /* 密碼注意大小寫 */ mysql> flush privileges; mysql> exit;
Restart the mysql service
The new root password will be set successfully.
3. Modify root login permissions
After you modify the root password , this situation is very likely to occur
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
This is because the root login permission is insufficient , the specific modification method is as follows
You need to stop the mysql service first. There are two situations here. One can use service mysqld stop,
The other is /etc/init.d/mysqld stop
When prompted that mysql has stopped, proceed to the next step Shutting down MySQL. SUCCESS!
Enter mysql on the terminal command line to log in to the mysql system
mysqld_safe --skip-grant-tables & /* 登錄mysql系統(tǒng) */
Then restart the mysql service.
First sentence: Log in as the authorized user root
Third sentence: View the mysql library The host value of the user table (that is, the host/IP name for connection access)
The fourth sentence: Modify the host value (add the host/IP address with the wildcard % content), of course you can also directly add the IP address
If there is an error in this step "ERROR 1062 (23000): Duplicate entry '%-root' for key 'PRIMARY'" It means that the record exists, skip this step
The fifth sentence: Refresh the MySQL system permissions related table
Sixth sentence: When checking the user table again, there are modifications. .
Restart the mysql service to complete.
MariaDB sets initialization password and changes password
mysql>use mysql; mysql>update user set host = ‘%’ where user = ‘root’; mysql>select host, user from user; mysql> flush privileges; mysql> exit; service mysqld/mysql statusservice mysqld/mysql restart/start
Method 2:
[root@localhost ~]# mysql MariaDB[(none)]> UPDATE mysql.user SET password = PASSWORD(‘newpassword’) WHERE USER = ‘root’; MariaDB[(none)]> FLUSH PRIVILEGES;
Method 3:
[root@localhost ~]# mysql MariaDB[(none)]> SET password=PASSWORD(‘newpassward’);
If root has set a password, use the following method
[root@localhost ~]# mysqladmin -u root password ‘newpassword’
How to modify Mysql under Linux ( Root's password and modification of root login permissions
The modified users are listed as root.
1. Know the root password of the original myql database;
①: In the terminal Enter mysqladmin -u root -p password "new password" on the command line, press Enter password: /* Enter the original old password */
②: Log in to the mysql system to modify, mysql -uroot -p press Enter password: /* Enter the original password */
[root@localhost ~]#mysqladmin -u root -p ‘oldpassword’ password ‘newpassword’
Then use the new password you just entered to log in.
2. I don’t know the original myql root password;
You need to first Stop the mysql service. There are two situations here. One can use service mysqld stop,
The other is /etc/init.d/mysqld stop
When prompted that mysql has stopped, proceed Next step: Shutting down MySQL. SUCCESS!
Enter
mysql>use mysql; mysql> update user set password=password(“新密碼”) where user=‘root’; /* 密碼注意大小寫 */ mysql> flush privileges; mysql> exit; service mysqld/mysql statusservice mysqld/mysql restart/start
in the terminal command line
mysqld_safe --skip-grant-tables & /* 登錄mysql系統(tǒng) */
Enter mysql to log in to the mysql system
mysql> use mysql; mysql> UPDATE user SET password=password(“新密碼”) WHERE user=‘root’; /* 密碼注意大小寫 */ mysql> flush privileges; mysql> exit;
Restart the mysql service
This way The new root password has been set successfully.
3. Modify root login permissions
After you modify the root password, this situation is likely to occur
ERROR 1045 (28000): Access denied for user ‘root’@‘localhost’ (using password: YES)
This It is because the root login permission is insufficient. The specific modification method is as follows
You need to stop the mysql service first. There are two situations here. One can use service mysqld stop,
The other is /etc/ init.d/mysqld stop
When prompted that mysql has stopped, proceed to the next step Shutting down MySQL. SUCCESS!
Enter on the terminal command line
mysqld_safe --skip-grant-tables & /* 登錄mysql系統(tǒng) */
Enter mysql to log in to mysql System
mysql>use mysql; mysql>update user set host = ‘%’ where user = ‘root’; mysql>select host, user from user; mysql> flush privileges; mysql> exit; service mysqld/mysql statusservice mysqld/mysql restart/start
Then restart the mysql service.
The first sentence: Log in as the authorized user root
The second sentence: Select the mysql library
The third sentence: View the host of the user table in the mysql library Value (the host/IP name for connection access)
Fourth sentence: Modify the host value (add the host/IP address with wildcard % content), of course you can also directly add the IP address
如果這步出錯(cuò)"ERROR 1062 (23000): Duplicate entry ‘%-root’ for key ‘PRIMARY’" 由說明該記錄有了,跳過這步
第五句:刷新MySQL的系統(tǒng)權(quán)限相關(guān)表
第六句:再重新查看user表時(shí),有修改。。
重起mysql服務(wù)即可完成。
MariaDB設(shè)置初始化密碼及修改密碼
方法1:
[root@localhost ~]# mysql MariaDB[(none)]> UPDATE mysql.user SET password = PASSWORD(‘newpassword’) WHERE USER = ‘root’; MariaDB[(none)]> FLUSH PRIVILEGES;
方法2:
[root@localhost ~]# mysql MariaDB[(none)]> SET password=PASSWORD(‘newpassward’);
方法3:
[root@localhost ~]# mysqladmin -u root password ‘newpassword’
如果root已經(jīng)設(shè)置過密碼,采用如下方法
[root@localhost ~]#mysqladmin -u root -p ‘oldpassword’ password ‘newpassword’
The above is the detailed content of How to change mysql database password under linux? How to change database password in Linux. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

The key to installing dual systems in Linux and Windows is partitioning and boot settings. 1. Preparation includes backing up data and compressing existing partitions to make space; 2. Use Ventoy or Rufus to make Linux boot USB disk, recommend Ubuntu; 3. Select "Coexist with other systems" or manually partition during installation (/at least 20GB, /home remaining space, swap optional); 4. Check the installation of third-party drivers to avoid hardware problems; 5. If you do not enter the Grub boot menu after installation, you can use boot-repair to repair the boot or adjust the BIOS startup sequence. As long as the steps are clear and the operation is done properly, the whole process is not complicated.

Newbie users should first clarify their usage requirements when choosing a Linux distribution. 1. Choose Ubuntu or LinuxMint for daily use; programming and development are suitable for Manjaro or Fedora; use Lubuntu and other lightweight systems for old devices; recommend CentOSStream or Debian to learn the underlying principles. 2. Stability is preferred for UbuntuLTS or Debian; you can choose Arch or Manjaro to pursue new features. 3. In terms of community support, Ubuntu and LinuxMint are rich in resources, and Arch documents are technically oriented. 4. In terms of installation difficulty, Ubuntu and LinuxMint are relatively simple, and Arch is suitable for those with basic needs. It is recommended to try it first and then decide.

The steps to add a new hard disk to the Linux system are as follows: 1. Confirm that the hard disk is recognized and use lsblk or fdisk-l to check; 2. Use fdisk or parted partitions, such as fdisk/dev/sdb and create and save; 3. Format the partition to a file system, such as mkfs.ext4/dev/sdb1; 4. Use the mount command for temporary mounts, such as mount/dev/sdb1/mnt/data; 5. Modify /etc/fstab to achieve automatic mount on the computer, and test the mount first to ensure correctness. Be sure to confirm data security before operation to avoid hardware connection problems.

Have problems uploading files in Google Chrome? This may be annoying, right? Whether you are attaching documents to emails, sharing images on social media, or submitting important files for work or school, a smooth file upload process is crucial. So, it can be frustrating if your file uploads continue to fail in Chrome on Windows PC. If you're not ready to give up your favorite browser, here are some tips for fixes that can't upload files on Windows Google Chrome 1. Start with Universal Repair Before we learn about any advanced troubleshooting tips, it's best to try some of the basic solutions mentioned below. Troubleshooting Internet connection issues: Internet connection

Logs in Linux systems are usually stored in the /var/log directory, which contains a variety of key log files, such as syslog or messages (record system logs), auth.log (record authentication events), kern.log (record kernel messages), dpkg.log or yum.log (record package operations), boot.log (record startup information); log content can be viewed through cat, tail-f or journalctl commands; application logs are often located in subdirectories under /var/log, such as Apache's apache2 or httpd directory, MySQL log files, etc.; at the same time, it is necessary to note that log permissions usually require s

sudo stands for "substituteuserdo" or "superuserdo", allowing users to run commands with permissions of other users (usually root). Its core uses include: 1. Perform system-level operations such as installing software or editing system files; 2. Accessing protected directories or logs; 3. Manage services such as restarting nginx; 4. Modify global settings such as /etc/hosts. When using it, the system will check the /etc/sudoers configuration and verify the user password, provide temporary permissions instead of continuously logging in as root, ensuring security. Best practices include: only when necessary, avoid blindly executing network commands, editing sudoers files with visudo, and considering continuous operations.

To manage Linux user groups, you need to master the operation of viewing, creating, deleting, modifying, and user attribute adjustment. To view user group information, you can use cat/etc/group or getentgroup, use groups [username] or id [username] to view the group to which the user belongs; use groupadd to create a group, and use groupdel to specify the GID; use groupdel to delete empty groups; use usermod-aG to add users to the group, and use usermod-g to modify the main group; use usermod-g to remove users from the group by editing /etc/group or using the vigr command; use groupmod-n (change name) or groupmod-g (change GID) to modify group properties, and remember to update the permissions of relevant files.

In Linux systems, 1. Use ipa or hostname-I command to view private IP; 2. Use curlifconfig.me or curlipinfo.io/ip to obtain public IP; 3. The desktop version can view private IP through system settings, and the browser can access specific websites to view public IP; 4. Common commands can be set as aliases for quick call. These methods are simple and practical, suitable for IP viewing needs in different scenarios.
