Basic operation of My sql database

Basic usage of My sql database

1. Cmd-enter the mysql -u root -p password 123456 command to enter the mysql user interface
2. Why set the environment variable: it is convenient to find mysql , if you don't configure it, you need to find the path of mysql and enter the command to make it My sql can be called in any directory.
3. JDBC: Java Database Connectivity, (Java Database Connectivity, referred to as JDBC) is an application program interface in the Java language used to regulate how client programs access the database, providing such as query and The method of updating data in the database.

My sql basic operation code:
mysql> show variables like'version'; query to display database version
mysql> show databases; display database
mysql> create database mydb; create database
mysql> use mydb; use target database
Database changed
mysql> create table users ( userID varchar(10), userName varchar(10)); create table
mysql> show tables; display table
mysql> insert into users values ​​('001','jxnu'); add
mysql> select * from users where userName like'% pk%';select
mysql> update users set userName='pk' where userID="003"; change
mysql> delete from users where usersID='003'; delete
mysql> drop database if exists mydb2; delete database
mysql> drop table if exists users2; delete table
mysql> alter table users
-> add userAge varchar(10);Add a list of attributes, increase the specified position is to use after, no before;
mysql> alter table users
-> rename users2; change the name of the attribute

Guess you like

Origin blog.csdn.net/weixin_44828960/article/details/108594121