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
Table of contents Cache function in vue2 Transfor...
PCIE has four different specifications. Let’s tak...
Use CSS to create a 3D photo wall. The specific c...
Preface: MySQL is a relational database managemen...
Table of contents 1minio is simple 2 Docker build...
Preface I recently encountered a problem at work....
1. When the width of the adjacent floating layer o...
Using SSH terminal (such as putty, xshell) to con...
Table of contents Start and stop Database related...
This article mainly describes how to implement fo...
Preface The electricity in my residence has been ...
Table of contents 1. Stop MySQL Server first 2. U...
Table of contents 1. Create components using func...
MyISAM and InnoDB are the most common storage eng...