After we install MySQL in the Linux system, we happily enter: mysql -u root -p in the terminal, and it prompts access denied... How to change MySQL password?
At this time you need to enter the /etc/mysql directory, then sudo vim/vi debian.cnf to view the user name and password inside, and then use the user in this file Enter mysql with your name and password. If the user name in debian.cnf is debian-sys-maint, then:
mysql -u debian-sys-maint -p Press Enter. You will be asked to enter your password. Copy Password in debian.cnf (do not enter it manually as errors are easy to occur).
You can now enter mysql
Change the root password
Log in to the mysql client according to the previous step
mysql> use mysql; Database changed mysql> update user set password=password('new password') where user='root'; Query OK, 4 rows affected (0.00 sec) Rows matched: 4 Changed: 4 Warnings: 0 mysql> flush privileges; Query OK, 0 rows affected (0.00 sec) mysql> quit
Log in with the newly changed root and password to view.
1. Open the terminal, enter sudo apt-get install phpmyadmin, and press Enter
2. Then, after the installation is completed, go to the apache server directory (already created by /var/www/html changed to /media/home/ivalley) and found that there is no phpmyadmin, such a file or folder
3. Here is the key point. When the system installs the software, the software will be installed by default. It is installed under /usr/share/, so your phpmyadmin can be found under /usr/share
4. Therefore, we must establish a soft connection so that the file displayed in the third step and /media To link to a document under /home/ivalley, enter the following code sudo ln -s /usr/share/phpmyadmin /media/home/ivalley/phpmyadmin
5. Next, open the browser and enter http ://localhost/phpmyadmin, enter your account name and password to log in smoothly and use the MySQL database happily
The above is the detailed content of How to change MySQL password in Linux. For more information, please follow other related articles on the PHP Chinese website!