mysql common instructions under linux operating system

Posted by raj86 on Sun, 29 Dec 2019 21:57:32 +0100

1. Access to MySQL database
It is completed by inputting mysql-uroot-p instruction, where uroot is the user name, and the option of inputting password will be displayed after execution

[it@VM_0_12_centos ~]$ mysql -uroot -p
Enter password: 

2. Display of existing database
Type show databases; on the command line to display the created databases

show databases;

3. Enter the established database
Type use aicallenger; in the command line to enter the specified database, where aicallenger is the name of the database to be entered

use AiChallenger;

4. Query all tables in the database
Type show tables; in the command line to view the established tables in the library

show tables;

5. Create database table
Type create table name; in the command line to create a new table
Note: in the Xshell software, the shortcut key for pasting under the linux system is ctrl+insert, and the shortcut key for copying is shift+insert

MariaDB [AiChallenger]> CREATE TABLE `Val_in_Challenger` (
    -> `id`  int NOT NULL AUTO_INCREMENT ,
    -> `content`  text NULL COMMENT 'Data text' ,
    -> `location_traffic_convenience`  int NULL COMMENT 'Whether the traffic is convenient' ,
    -> `location_distance_from_business_district`  int NULL  COMMENT 'Distance to business district' ,
    -> `location_easy_to_find`  int NULL COMMENT 'Is it easy to find' ,
    -> `service_wait_time`  int NULL COMMENT 'Waiting time' ,
    -> `service_waiters_attitude`  int NULL COMMENT 'Service staff attitude' ,
    -> `service_parking_convenience`  int NULL COMMENT 'Is it easy to park' ,
    -> `service_serving_speed`  int NULL COMMENT 'May I take your order?/Serving speed' ,
    -> `price_level`  int NULL COMMENT 'price level' ,
    -> `price_cost_effective`  int NULL COMMENT 'Cost performance' ,
    -> `price_discount`  int NULL COMMENT 'Discount strength' ,
    -> `environment_decoration`  int NULL COMMENT 'Decoration situation' ,
    -> `environment_noise`  int NULL COMMENT 'Noisy situation' ,
    -> `environment_space`  int NULL COMMENT 'Dining space' ,
    -> `environment_cleaness`  int NULL COMMENT 'Hygienic condition' ,
    -> `dish_portion`  int NULL COMMENT 'Weight' ,
    -> `dish_taste`  int NULL COMMENT 'Texture' ,
    -> `dish_look`  int NULL COMMENT 'Appearance' ,
    -> `dish_recommendation`  int NULL COMMENT 'Recommendation degree' ,
    -> `others_overall_experience`  int NULL COMMENT '  This consumption experience' ,
    -> `others_willing_to_consume_again`  int NULL COMMENT 'Willingness to consume again' ,
    -> PRIMARY KEY (`id`),
    -> FULLTEXT INDEX `findword` (`content`) 
    -> )ENGINE=MyISAM,
    -> COMMENT='AI_Challenger Challenge training set data'
    -> ;

After the command is executed, type show tables again, and observe that the val_in_

Topics: Database MySQL Linux MariaDB