Common MySQL commands in Linux

Source: Internet
Author: User
To use Linux and MySQL, you must be familiar with Common commands. The following are some common commands collected:

To use Linux and MySQL, you must be familiar with Common commands. The following are some common commands collected:

To use Linux and MySQL, you must be familiar with Common commands. The following are some common commands collected:

1. commands for starting mysql in linux:
Mysqladmin start
/Ect/init. d/mysql start (the installation path of mysql is earlier)

2. Command for restarting mysql in linux:
Mysqladmin restart
/Ect/init. d/mysql restart (the installation path of mysql is earlier)

3. Run the following command to disable mysql in linux:
Mysqladmin shutdown
/Ect/init. d/mysql shutdown (the installation path of mysql is earlier)

4. Connect to mysql on the local machine:
Enter the mysql \ bin directory, type the mysql-uroot-p command, and press enter to enter the password.
Exit mysql command: exit (Press ENTER)

5. Modify the mysql password:
Mysqladmin-u username-p old password New password
Or enter the mysql command line set password for root = PASSWORD ("root ");

6. Add new users. (Note: commands in the mysql environment are followed by a semicolon as the command Terminator)
Grant select on database. * to username @ login host identified by "password"
For example, if a user's test password is added to 123, the user can log on to any host and have the permission to query, insert, modify, and delete all databases. First, use the root user to connect to mysql, and then type the following command:
Grant select, insert, update, delete on *. * to "Identified by" 123 ";

Ii. mysql database operations


You must first log on to mysql. The related operations are performed at the mysql prompt, and each command ends with a semicolon.

1. display the Database List.
Show databases;
2. display the data tables in the database:
Use mysql; // open the database
Show tables;
3. display the data table structure:
Describe table name;
4. database creation:
Create database name;
5. Create a table:
Use Database Name;
Create table Name (field setting list );
6. Delete databases and tables:
Drop database name;
Drop table name;
7. Clear records in the table:
Delete from table name;
8. Display records in the table:
Select * from table name;

9. Encoding Modification
To change the encoding format of mysql:
When mysql is started, add the mysqld_safe command line
-- Default-character-set = gbk

To change the encoding format of a Database: Enter the command at the mysql prompt
Alter database db_name default character set gbk;

,

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.