Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the common operation instructions of MySQL in Linux terminal

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

Xiaobian to share with you what MySQL common operating instructions in Linux terminal, I hope you have gained something after reading this article, let's discuss it together!

Services:

# chkconfig --list List all system services # chkconfig --list| grep on # chkconfig --list mysqld # whereis mysql view file install path # which mysql Query the path where the running file is located (folder address)usr/bin/mysql refers to: mysql running path var/lib/mysql refers to: mysql database file storage path usr/lib/mysql refers to: 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 Stop MySQL

2. Enter MySQL Form Operations

# -u root -p /mysql -h localhost -u root -p DatabaseName; Enter MySQL> show databases; MySQL> create database XXX; MySQL> use databaseName; database name 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 forms MySQL> drop table mytablename ; MySQL> drop database name; delete database

3. additions and deletions to search

MySQL> insert into mytablename values (','zhangsan',' 123456','fomale','guiyanag'); insert MySQL> select * from mytablename ; MySQL> select * from mytablename where ID ='1 '; accurately find MySQL> update mytablename set address ='shanghai' where username ='zhangsan '; modify zhangsan address to shanghaiMySQL> delete from mytablename where ID ='1'; delete records

Add universal users

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

username user_1 password is 123456

This user can log in to the database from any PC

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

Create native-only users who can work with databases

username user_2 password is 123456

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

Log in to the database

MySQL> -u user_1 -p -h IP address; After reading this article, I believe you have a certain understanding of "What are MySQL common operation instructions in Linux terminals". If you want to know more about this knowledge, please pay attention to the industry information channel. Thank you for reading!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report