Commonly used MySQL commands in Linux system: linuxmysql
Service:
# Chkconfig -- list all system services
# Chkconfig -- list | grep on lists all started system services
# Chkconfig -- list mysqld
# Whereis mysql viewing File Installation path
# Which mysql query the path of the running file (Folder address)
Usr/bin/mysql indicates the mysql running path.
Var/lib/mysql refers to the storage path of mysql database files.
Usr/lib/mysql indicates the installation path of mysql.
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; enter MySQL
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 form
MySQL> drop table mytablename; delete a form
MySQL> drop database databasename; delete database
3. add, delete, modify, and query
MySQL> insert into mytablename values ('', 'zhangsan', '123', 'fomale', 'guiyanag'); insert
MySQL> select * from mytablename; search for verification results
MySQL> select * from mytablename where ID = '1'; precise search
MySQL> update mytablename set address = 'shanghai' where username = 'hangsan '; change the address of zhangsan
MySQL> delete from mytablename where ID = '1'; delete a 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;
I also attached some frequently-used commands for your reference:
Other mysql database-related operations are as follows:
(1) create a database TestDB mysql> create database TestDB;
(2) set the TestDB database to the current default database mysql> use TestDB;
(3) create a table customers mysql> create table customers (userid int not null, username varchar (20) not null) in the TestDB database );
(4) display the Database List mysql> show databases;
(5) display the mysql> show tables in the database;
(6) Delete the customers mysql> drop table customers;
(7) display the customers table structure mysql> desc customers;
(8) insert a record mysql> insert into MERs (userid, username) values (1, 'hujiahui') into the MERs table ');
(9) make the operation take effect in time; mysql> commit;
(10) query the record mysql> select * from MERs in mers MERS;
(11) update the data in the table mysql> update MERs set username = 'dennishu' where userid = 1;
(12) delete the record mysql> delete from MERs in the table;
(13) grant the likui user the permission to access the database # grant select, insert, update, delete on *. * to likui @ localhost indentified by "123456 ";