MySQL basic operation MySQL password reset

Source: Internet
Author: User

☆ NOTE: MySQL database installation is not introduced, because everyone installation path is different, so this step ignored, said the focus:

1. Initialize MySQL database/usr/local/mysql/scripts/mysql_install_db--user=mysql--basedir=/usr/local/mysql--datadir=/usr/ Local/mysql/data--defaults-file=/etc/my.cnf2. Start the MySQL setup system cp/usr/local/mysql/support-files/mysql.server/etc/ Init.d/mysqldchmod +x/etc/init.d/mysqldchkconfig--add mysqld chkconfig--level 3 mysqld on3. Start Mysql/etc/init.d/mysqld Start

4. The default login MySQL is no password (Mysql-uroot can log in), obviously MySQL does not have login password is absolutely no, next operation:

/usr/local/mysql/bin/mysqladmin-uroot password ' Xiaohai ' then log in to the MySQL database/usr/local/mysql/bin/mysql-uroot-pxiaohai And then you can log in to the database.

"The question comes, what if the root password of MySQL is forgotten?" 】

In fact, the operation is very simple, first stop the MySQL database, the operation is as follows:

1./etc/init.d/mysqld Stop2. In/ETC/MY.CNF's [mysqld] statement, condition a statement: [Mysqld]skip-grant-tables so it's OK, then save the exit! 3. Restart Mysql/etc/init.d/mysqld restart 4. Connect MySQL database directly after reboot/usr/local/mysql/bin/mysql-uroot can enter MySQL operation in database: use MySQL; Update user Set Password = password (' [email protected] #xiaohai ') where user= ' root '; flush privileges;

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/75/04/wKiom1Ywhl2jQMzNAAEMtCYWHeU477.jpg "title=" Sql.png "alt=" Wkiom1ywhl2jqmznaaemtcywheu477.jpg "/>

5. Remove the amount Skip-grant-tables just added to the/etc/my.cnf file, then restart MySQL to log in to the database, and the login password is the password you just reset.


"MySQL Database Export"

1.mysql-uroot [email protected] #xiaohai mysql >/data/mysql.sql export the MySQL library in the database to the/data/directory and named Mysql.sql

"MySQL Database import"

2.mysql-uroot [email protected] #xiaohai MySQL </data/mysql.sql import the Mysql.sql file into the MySQL library of the database


This article is from the "Small Sea" blog, please be sure to keep this source http://hason.blog.51cto.com/8271396/1707332

MySQL basic operation MySQL password reset

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.