Modify the default MySQL root management password in Linux

Source: Internet
Author: User

Important directories of Linux MySQL

1. Database directory
/Var/lib/mysql/
2. Configuration File
/Usr/share/mysql (mysql. server command and configuration file)
3. Related commands
/Usr/bin (commands such as mysqladmin mysqldump)
4. Start the script

/Etc/rc. d/init. d/(directory for starting the script file mysql)

Changing the logon password for Linux MySQL

Linux MySQL does not have a password by default. It is self-evident that the password is added after installation.

1. Commands
Usr/bin/mysqladmin-u root password 'new-password'
Format: mysqladmin-u username-p old password New password

2. Example
Example 1: Add a 123456 password to the root user.
Type the following command:
[Root@www.bkjia.com local] #/usr/bin/mysqladmin-u root password123456
Note: because the root account does not have a password at the beginning, the old-p password can be omitted.

3. test whether the modification is successful
1) login without a password
[Root@www.bkjia.com local] # mysql
ERROR 1045: Access denied for user: 'root @ localhost' (Usingpassword: NO)
An error is displayed, indicating that the password has been modified.
2) log on with the modified Password
[Root@www.bkjia.com local] # mysql-u root-p
Enter password: (Enter the password 123456 after modification)
Welcome to the MySQL monitor. Commands end with; or \ g.
Your MySQL connection id is 4 to server version: 4.0.16-standard
Type 'help; 'or' \ H' for help. Type '\ C' to clear the buffer.
Mysql>
Successful! You can use the mysqladmin command to change the password or the database to change the password.

Linux MySQL Start and Stop

1. Start
After MySQL is installed, run the following command to start mysql in the/etc/init. d directory.
[Root@www.bkjia.com init. d] #/etc/init. d/mysql start another installer installs MySQL as a service, so you can use # service mysql start to start LinuxMySQL in any directory.
2. Stop
/Usr/bin/mysqladmin-u root-p shutdown or: # service mysqlstop
3. Automatic Start
1) Check whether mysql is in the Auto Start List
[Root@www.bkjia.com local] #/sbin/chkconfig-list
2) Add Linux MySQL to the startup Service Group of your system.
[Root@www.bkjia.com local] #/sbin/chkconfig-add mysql
3) Delete Linux MySQL from the startup Service Group.
[Root@www.bkjia.com local] #/sbin/chkconfig-del mysql

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.