Use MySQL in Linux -- forget the root password and modify the default MySQL encoding, mysqlroot

Source: Internet
Author: User
Tags mysql login

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 % ';


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.