Command 1 to start mysql in linux. command for starting mysql in linux: mysqladmin start www.2cto.com/ect/init. d/mysql start (the installation path of mysql is earlier) 2. command for restarting mysql in linux: mysqladmin restart/ect/init. d/mysql restart (the preceding mysql installation path) 3. command for disabling mysql in linux: mysqladmin-u root-p password shutdown/ect/init. d/mysql shutdown (the installation path of mysql is earlier) 4. connect to mysql on the local machine: Enter the mysql \ bin directory, type the mysql-uroot-p command, and press enter to enter the password. Exit mysql command: exit (Press ENTER) 5. modify mysql password: www.2cto.com mysqladmin-u username-p old PASSWORD new password or enter mysql command line set password for 'username' @ 'host' = PASSWORD ('Password '); grant usage on *. * TO 'username '@ 'host' identified by 'biscuit'; change your password set password = PASSWORD ('biscuit'); 6. add new users. (Note: commands in the mysql environment are followed by a semicolon as the command Terminator.) grant all privileges on *. * to username @ '%' identified by 'Password' with grant option; flush privileges; (refresh permission settings) grant select on database. * to username @ login host identified by "password". If a user test password is added to 123, the user can log on to any host, all databases are permitted to query, insert, modify, and delete databases. First, use the root user to connect to mysql, and then type the following command: grant select, insert, update, delete on *. * to "Identified by" 123 "; 7. skip authorized access to mysql mysqld_safe -- user = mysql -- skip-grant-tables -- skip-networking & 2. You must first log on to mysql for mysql database operations, the related operations are performed at the mysql prompt, and each command ends with a semicolon (;). 1. The database list is displayed. Www.2cto.com show databases; 2. display the data table in the database: use mysql; // open the database show tables; 3. display the data table structure: describe table name; 4. create database: create database name; 5. create a table: use database Name; create table Name (field setting list); 6. delete database and table: drop database name; drop table name; 7. Clear the records in the Table: delete from table name; 8. display the records in the Table: select * from table name; 9. Modify the encoding if you want to change the encoding format of mysql: when mysql is started, add the mysqld_safe command line to www.2cto.com -- default-character-set = gbk. If you want to change the encoding format of a database: Enter the alter database d command at the mysql prompt. B _name default character set gbk; 3. Data Import and Export 1. The format of text data to be transferred to the database is as follows: field data is separated by the tab key, and null value is used instead. Example: 1 name duty 2006-11-23 data import command load data local infile "file name" into table name; 2. Export Database and table mysqldump -- opt news> news. SQL (back up all the tables in the database news to news. SQL file, news. SQL is a text file with any file name .) Mysqldump -- opt news author article> author. article. SQL (back up the author table and article table in the database news to author. article. SQL file, author. article. SQL is a text file with any file name .) Mysqldump -- databases db1 db2> news. SQL (back up database dbl and db2 to the news. SQL file. news. SQL is a text file with any file name .) Mysqldump-h host-u user-p pass -- databases dbname> file. dump is to import the database dbname named "user" and "password pass" on the host to the file. mysqldump -- all-databases> all-databases. SQL in dump (back up all the databases to all-databases. SQL files, the all-databases. SQL is a text file, any file name .) 3. Import Data mysql <all-databases. SQL (import database) mysql-u root-p fukai-force <dmc010003_db.myisam. SQL (force import) mysql> source news. SQL; (run the mysql command to import tables) common options of MySQLimport: www.2cto.com-d or -- delete all information in the data table before the new data is imported into the data table-f or -- force whether or not an error occurs, mySQLimport will force the insertion of data-I or -- ignore MySQLimport to skip or ignore rows with the same unique keyword. The data in the import file will be ignored. -L or-lock-tables: The table is locked before data is inserted. This prevents you from affecting your queries and updates when updating the database. -R or-replace is opposite to-I. This option replaces records with the same unique keywords in the table. -- Fields-enclosed-by = char specifies the data record in a text file. In many cases, the data is enclosed by double quotation marks. By default, data is not enclosed by characters. -- Fields-terminated-by = char specifies the delimiter between values of each data. In a file separated by periods, the Delimiter is a period. You can use this option to specify the delimiter between data. The default Delimiter is the Tab character -- lines-terminated-by = str. This option specifies the delimiter string or character used to separate the data between rows and rows in a text file. By default, MySQLimport uses newline as the line separator. You can choose to use a string to replace a single character: a new line or a carriage return. Common options of the MySQLimport command include-v display version. For example,-p prompts you to enter a password: the statement format of the row of the imported file is as follows: "1", "ORD89876", "1 Dozen Roses ", "19991226" our task is to import the data in this file to the table Orders in the database Meet_A_Geek. We use this command: bin/MySQLimport-Prolactin-fields-enclosed-by = "-fields-terminated-by =, Meet_A_Geek Orders.txt www.2cto.com I. Connection to MySQL format: mysql-h host address-u user name-p User Password 1. Example 1: connect to MYSQL on the local machine. First, open the DOS window, enter the directory mysqlbin, then type the command mysql-uroot-p, and press enter to prompt you to enter the password. If you have just installed MYSQL, super User root has no password, so press enter to enter MYSQL. The MYSQL prompt is: mysql>. 2. Example 2: connect to MYSQL on the remote host. Assume that the IP address of the remote host is 110.110.110.110, the user name is root, and the password is abcd123. Run the following command: mysql-h110.110.110.110-uroot-pabcd123 (Note: you do not need to add spaces to the u and root nodes.) 3. exit MYSQL: exit (Press ENTER ). Mysql common maintenance commands 1. show global status; list various status values of MySQL server running 2. show variables; query MySQL server configuration information statement 3. View slow query show variables like '% slow %'; show global status like '% slow % '; 4. max connections show variables like 'max _ connections '; Max _ used_connections for MySQL servers www.2cto.com show global status like 'max _ used_connections'; max connections for server responses 5. view the table structure desc Tablename; describe Tablename; show columns from Tablename; show create table Tablename; Author: Li jiashun