Detailed description of MySQL common operation commands on Linux terminal, linuxmysql

Source: Internet
Author: User

Detailed description of MySQL common operation commands on Linux terminal, linuxmysql

Service:

# Chkconfig -- list listing all system services # chkconfig -- list | grep on listing all started system services # chkconfig -- list mysqld # whereis mysql viewing File Installation path # which mysql querying the running File PATH (Folder address) usr/bin/mysql indicates the mysql running path. var/lib/mysql indicates the mysql database file storage path. usr/lib/mysql indicates the mysql installation path.

Add environment variables:

# vi /etc/profile# export MYSQL_HOME=/usr/local/mysql# export PATH=$PATH:$MYSQL_HOME/bin

1. database commands:

# Service mysqld start MySQL # service mysqld restart MySQL # service mysqld stop MySQL

2. Enter the MySQL form operation

#-U root-p/mysql-h localhost-u root-p DatabaseName; go to MySQL> show databases; list databases MySQL> create database XXX; create Database XXX MySQL> use databaseName; use Database databaseName MySQL> show tables; list forms MySQL> create table mytablename (ID int auto_increment not null primary key, usename varchar (20 ), password varchar (64), sex varchar (10), address varchar (20); create a form MySQL> drop table mytablename; delete a form MySQL> drop database databasename; delete a database

3. add, delete, modify, and query

MySQL> insert into mytablename values ('', 'hangsan', '000000', 'fomale', 'guiyanag '); insert MySQL> select * from mytablename; query the verification result MySQL> select * from mytablename where ID = '1'; precise search for MySQL> update mytablename set address = 'shanghai' where username = 'hangsan '; change the address of zhangsan to shanghaiMySQL> delete from mytablename where ID = '1'; delete record

Add universal users

grant select On database.* to username@localhost identity by 'password'

User_1 password is 123456

You can log on to the database from any PC.

MySQL> grant select,insert update,delete on *.* to user_1@"%" identity by "123456";

Create a user who can operate databases only on the local machine

Username user_2 password is 123456

MySQL> grant select,insert update,delete on *.* to user_2@localhost identity by "123456";

Log on to the database

MySQL>-u user_1-p-h IP address;

Summary

The above is a common MySQL operation instruction on Linux terminal introduced by xiaobian. I hope it will be helpful to you. If you have any questions, please leave a message and I will reply to you in a timely manner. Thank you very much for your support for the help House website!

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.