Use mysql--to forget root password and modify MySQL default code under Linux

Source: Internet
Author: User
Tags mysql login mysql view

Overview:

This blog is no longer on the MySQL grammar to explain and explain, want to know or familiar with the friends please Baidu or Google to learn. This blog is mainly for MySQL except grammar summary, hope can also help you.


1.centos6.x MySQL forgot root password solution

Ⅰ. Modifying login settings for MySQL

# VIM/ETC/MY.CNF

Add one sentence to the [mysqld] paragraph: skip-grant-tables


Ⅱ. Restart Service

# Service Mysqld Restart


Ⅲ. Log in to MySQL, change password information

# MySQL

mysql> use MySQL;

mysql> UPDATE user SET Password=password (' New-password ') WHERE user= ' root ';

mysql> flush Privileges;

Mysql> quit


Ⅳ. Restoring MySQL Login settings

# VIM/ETC/MY.CNF

Add a skip-grant-tables comment to the paragraph in [mysqld] or delete


Ⅴ. Restart Service

# Service Mysqld Restart


2.centos6.x modifying MySQL default encoding

Ⅰ. Log in to MySQL view encoding format

Show variables like ' character% ';


Ⅱ. Copying my-large.cnf files to/etc/my.cnf
Cp/usr/share/doc/mysql-server-4.1.12/my-large.cnf/etc/my.cnf


Ⅲ. Edit the My.cnf file to modify the default encoding format
Vim/etc/my.cnf
Add Default-character-set=utf8 in the [mysqld] Segment

Add Default-character-set=utf8 in the [client] segment


Ⅳ. # service MYSQLD Restert # Restart Services


Ⅴ. Verifying the success of the modification: show variables like ' character% ';


Use mysql--to forget root password and modify MySQL default code under Linux

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.