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!