Summary
In this blog post. The author will start from the foundation. Describes the installation and basic use commands for MySQL in Linux, only for people who have just started learning from MySQL. Daniel, please take a detour ...
Installing the MySQL Database
Here is the simplest way to install, as for compiling the installation, the ability to download the installation package,./configure generate makefile. Then make clean, make, make test, make install I think these commands should be very basic, it is no longer allocations.
1. Installation commands
[Email protected]:~$ sudo apt-get install mysql-server mysql-client
2. View the database version number, where password is "11"
[Email protected]:~$ sudo mysqladmin-u root-p versionenter password:mysqladmin Ver 8.42 distrib 5.1.70, for debian- Linux-gnu on I486copyright (c) +, Oracle and/or its affiliates. All rights reserved.
3. Check the status of the MySQL service. Start or close the MySQL service
[Email protected]:~$ service MySQL statusmysql start/running, process 899[email protected]:~$ Sudo/etc/init.d/mysql Star T|stop|restart
4. Log in to the database. and exit the operation
The command of-U refers to the username, which refers to the root,-p after the password, this refers to the installation of the database when the password set, the author of the 11
[Email protected]:~$ sudo mysql-uroot-p11
5. Basic operations within the database
Show Database mysql> show databases;+--------------------+| Database |+--------------------+| information_schema | | jxc | | mysql |+--------------------+3 rows in Set (0.08 sec)//Use a database mysql> using mysqlreading table information for completion of table and column namesyou can turn off This feature to get a quicker startup With-adatabase changed//Create the database mysql> created databases thinkphp; Query OK, 1 row Affected (0.00 sec)//delete database mysql> drop db thinkphp; Query OK, 0 rows affected (0.07 sec)//display a table in the database mysql> show tables;//show the structure of a table mysql> describe slow_log;//Select the displayed table contents m Ysql> select * from Slow_log; Empty Set (0.00 sec)//Delete tables mysql> drop table slow_log;//Import Database mysql> source/var/www/webpage.sql; or command: ~$ sudo mysql –UROOT–P11 Thinktest < Webpage.sql
MySQL table structure CRUD operations
Add table field ALTER TABLE tablename add elemname varchar (ten) not NULL; Alter a table field type alteration table tablename Change elemname elem NewName varchar () null; ALTER TABLE TableName Modify elemname varchar (ten) null; Delete a field ALTER TABLE tablename drop elemname; Insert data into datasheet INSERT INTO TableName (elem1,elem2,...) VALUES (A, b,...); Deleting data in data table delete from tablename where id>1 order by time limit 1; Update data in Datasheet
??
MySQL installation and use in Ubuntu system