Use MySQL in Linux -- forget the root password and modify the default MySQL encoding, mysqlroot
Overview:
This blog will not explain or explain MySQL syntax any more. If you want to know or be familiar with MySQL, Please study it on your own Baidu or Google. This blog is mainly for the summary of MySQL in addition to syntax, and hopes to help you.
1. Solution to MySQL forgetting the root password in CentOS6.x
I. Modify MySQL login settings
# Vim/etc/my. cnf
In the [mysqld] section, add skip-grant-tables.
Ii. Restart the service
# Service mysqld restart
Iii. log on to Mysql and change the password.
# Mysql
Mysql> USE mysql;
Mysql> UPDATE user SET Password = password ('new-password') WHERE User = 'root ';
Mysql> flush privileges;
Mysql> quit
Iv. Restore Mysql login settings
# Vim/etc/my. cnf
Comment out or delete the skip-grant-tables added to the [mysqld] segment
V. Restart the service
# Service mysqld restart
2. CentOS6.x modify the default MySQL Encoding
I. log on to Mysql to view the encoding format
Show variables like 'character % ';
Ii. Copy the my-large.cnf file to/etc/my. cnf
Cp/usr/share/doc/mysql-server-4.1.12/my-large.cnf/etc/my. cnf
Iii. Edit the my. cnf file and modify the default encoding format
Vim/etc/my. cnf
Add default-character-set = utf8 in the [mysqld] Section
Add default-character-set = utf8 in the [client] segment
Iv. # service mysqld restert # restart the service
V. verify whether the modification is successful: show variables like 'character % ';