Preferred to use Putty to connect to Linux servers for command line
Enter mysql-u+ database user-p+ Database password
Set up database user is the root password is 123, should be like the following is the correct:
Mysql-uroot-p123
-U and-P connection database users and passwords cannot have spaces in between
Below to create the database MyDatabase
Create DATABASE MyDatabase;
So a database called MyDatabase is created.
show databases; Show All Database lists
Drop DATABASE MyDatabase; Delete Database MyDatabase
So how do you exit the MySQL command line?
Enter exit at the terminal; Know completely quit MySQL command behavior stop
Attached to some of the most commonly used commands
(4) Make the TestDB database the current default database
mysql> use TestDB;
(5) Create a table in the TestDB database customers
mysql> CREATE TABLE Customers (userid int NOT NULL, username varchar () not NULL);
(6) Display the list of databases
mysql> show databases;
(7) Display the table in the database
mysql> show tables;
(8) Delete Table Customers
mysql> drop table customers;
(9) Display the structure of the Customers table
mysql> desc customers;
(10) Insert a record into the Customers table
Mysql> INSERT INTO Customers (UserID, username) VALUES (1, ' Hujiahui ');
(11) Let the operation take effect in time;
Mysql> commit;
(12) Querying records in Customers
Mysql> select * from Customers;
(12) Update the data in the table
mysql> Update customers set Username= ' Dennishu ' where userid=1;
(13) Delete the records in the table
Mysql> Delete from customers;
(14) Grant HJH user access to the database
# Grant SELECT, INSERT, UPDATE, delete on *.* to Hjh@localhost indentified by "123456";
Remarks: Hjh Is the Linux username, 123456 is access to the MySQL password
(15) with username and password login mysql
# mysql-uhjh-p123456