Serve: # chkconfig --list List all system services # chkconfig --list | grep on List all started system services # chkconfig --list mysqld # whereis mysql View the file installation path # which mysql Query the path where the running file is located (folder address) usr/bin/mysql refers to: the running path of mysql var/lib/mysql refers to: the storage path of mysql database files usr/lib/mysql refers to: 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 instructions: # service mysqld start Start MySQL # service mysqld restart Restart MySQL # service mysqld stop 2. Enter the MySQL form operation # -u root -p /mysql -h localhost -u root -p DatabaseName; Enter MySQL MySQL> show databases; List databasesMySQL> create database XXX; Create database XXX MySQL> use databaseName; Use database databaseName MySQL> show tables; List tablesMySQL> create table mytablename (ID int auto_increment not null primary key,usename varchar(20),password varchar(64),sex varchar(10),address varchar(20)); Create tableMySQL> drop table mytablename; Delete tableMySQL> drop database databasename; Delete database 3. Add, delete, modify and check MySQL> insert into mytablename values('','zhangsan','123456','fomale','guiyanag'); InsertMySQL> select * from mytablename; Find verification resultsMySQL> select * from mytablename where ID = '1'; Accurate searchMySQL> update mytablename set address = 'shanghai' where username = 'zhangsan'; Change zhangsan's address to shanghai MySQL> delete from mytablename where ID = '1'; Delete records Add universal user grant select On database.* to username@localhost identity by 'password' Username user_1 Password is 123456 You can log in as this user from any PC to operate the database MySQL> grant select,insert update,delete on *.* to user_1@"%" identity by "123456"; Create a user who can only operate the database on this machine Username user_2 Password is 123456 MySQL> grant select,insert update,delete on *.* to user_2@localhost identity by "123456"; Login database MySQL> -u user_1 -p -h IP address; Summarize The above are the common operating instructions of MySQL in Linux terminal introduced by the editor. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website! You may also be interested in:
|
<<: Detailed explanation of EXT series file system formats in Linux
>>: Implementing a web calculator based on JavaScript
Preface This article summarizes some common MySQL...
This article example shares the specific code of ...
Table of contents Implementing state sharing base...
A transaction is a logical group of operations. E...
The following attributes are not very compatible w...
Method 1: Use the SET PASSWORD command MySQL -u r...
Preface I have seen many articles about the leftm...
It is also very simple to deploy Django projects ...
Implementation of navigation bar, fixed top navig...
The before/after pseudo-class is equivalent to in...
On the server, in order to quickly log in to the ...
1. Install Docker First open the Linux environmen...
Table of contents Scope Global Scope Function Sco...
Table of contents 1. Background 2. Operation step...
Table of contents use Use of EsLint Add a profile...