MySQL Startup change Password

Source: Internet
Author: User
Tags lost password mysql login

I. MySQL Startup method
1./etc/init.d/mysqld start
2./usr/local/mysql/bin/mysqld_safe--user=mysql &

&: Start MySQL service on behalf of the background

two. mysql Login method:
1. The system does not have the password condition: MySQL or Mysql-uroot
2. Standard method of landing: Mysql-uroot-p
3. Multi-Instance Login method:
Mysql-uroot-p-s/data/3306/mysql.sock #指定下sock文件
Mysql-uroot-p-s/data/3307/mysql.sock
three. mysql Shutdown method
1. Close with a dedicated script
four. mysql build user. and authorization Method
1. The method of 2 steps:
Create user ' test ' @ ' localhost ' identified by ' test11 ';
Grant SELECT on mysql.* to ' test ' @ ' localhost ';
2. A direct command:
Mysql> Grant Select on mysql.* to ' test2 ' @ ' localhost ' identified by ' test22 ';
Query OK, 0 rows Affected (0.00 sec)
Mysql> select User,host from user;
+-----------+-----------+
| user | Host |
+-----------+-----------+
| Root | 127.0.0.1 |
| Root | localhost |
| Test | localhost |
| Test2 | localhost |
| WordPress | localhost |
+-----------+-----------+
5 rows in Set (0.00 sec)
five. MySQL Change Password method:
1. After installation, set the password method:
A.mysqladmin-uroot-password ' test88 '
B.mysqladmin-uroot-password ' test88 '-s/data/3306/mysql.sock #多实例的例子
2. Change the password
A. [Email protected]~]# mysqladmin-uroot-p ' mybaby99 ' password ' ainini99 '
b. [Email protected]~]# mysqladmin-uroot-p ' mybaby99 ' password ' ainini99 '-s/data/3306/mysql.sock
six. Recover lost Password:
1. Single Instance
[Email protected] ~]# Killall mysqld
[Email protected] ~]# mysqld_safe--skip-grant-table & mysql-uroot-p
mysql> use MySQL;
Database changed
mysql> Update user Set Password=password (' mygirl99 ') where user= ' root ';
Query OK, 2 rows Affected (0.00 sec)
Rows matched:2 Changed:2 warnings:0

mysql> flush Privileges;
Query OK, 0 rows Affected (0.00 sec)

You may also be interested in the contents of MySQL compilation parameter review

MySQL Startup change Password

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.