. Linux to start the MySQL tutorial command:
Mysqladmin start
/ect/init.d/mysql Start (Previous installation path for MySQL)
2.linux Restart MySQL command:
Mysqladmin restart
/ect/init.d/mysql Restart (previous installation path for MySQL)
3.linux to close MySQL command:
Mysqladmin shutdown
/ect/init.d/mysql Shutdown (Previous installation path for MySQL)
4. Connect MySQL on this computer:
Enter the directory Mysqlbin, then type the command mysql-uroot-p and prompt for the password when you enter.
Exit MySQL command: Exit (enter)
5. Modify MySQL Password:
Mysqladmin-u username-p Old password password new password
or enter the MySQL command line set password for Root=password ("root");
6. Add new users. (Note: The commands in the MySQL environment are followed by a semicolon as the command Terminator)
Grant Select on database Tutorial. * To User name @ login host identified by "password"
If you add a user test password of 123, so that he can log on any host, and all databases have query, insert, modify, delete permissions. First connect the root user to MySQL, and then type the following command:
Grant Select,insert,update,delete on *.* to "identified by" 123;
Second, the MySQL database aspects of the operation
You must first log in to MySQL, the operation is done under the MySQL prompt, and each command ends with a semicolon
1. Display the list of databases.
show databases;
2, display the data table in the library:
use MySQL;//Open Library
Show tables;
3, display the structure of the data table:
describe table name;
4, build the library:
Create database library name;
5, the establishment of the table:
Use library name;
CREATE TABLE table name (field set list);
6, delete the database and delete the table:
drop Database library name;
The drop table table name;
7. Empty the record of the table:
Delete from table name;
8, display the records in the table:
SELECT * from table name;
9, the Code modification
If you want to change the entire MySQL encoding format:
When you start MySQL, the Mysqld_safe command line joins
--default-character-set=gbk
If you want to change the encoding format of a library: Enter a command after the MySQL prompt
ALTER DATABASE db_name default character set GBK;
Iii. Import and export of data
1, the text data to go to the database
The format that text data should conform to: field data is separated by a TAB key and Null values are used instead. Cases:
1 Name Duty 2006-11-23
Data incoming command load infile "filename" into table name;
2. Export Database and table
Mysqldump--opt News > News.sql (backs up all tables in the database news to news.sql files, News.sql is a text file, and the filename is optional.) )
Mysqldump--opt News Author article > Author.article.sql (backs up author tables and article tables in the database news to author.article.sql files. Author.article.sql is a text file, and the filename is optional. )
Mysqldump--databases db1 DB2 > News.sql (Backup Database dbl and DB2 to News.sql file, News.sql is a text file, file name is optional.) )
Mysqldump-h host-u user-p pass--databases dbname > File.dump
is to import the database dbname in the host with the name user, password pass to the file File.dump
Mysqldump--all-databases > All-databases.sql (Backup all databases to All-databases.sql file, All-databases.sql is a text file, file name is optional.) )