MySQL database command line tool _ MySQL

Source: Internet
Author: User
MySQL database command line tool bitsCN.com
MySQL database command line tool MySQL includes a server process to manage the database, as well as a series of tools for accessing the database and creating applications: mysql: execute SQL queries in MySQL, you can also execute SQL commands stored in files; mysqlaccess: manage users; mysqladmin: manage database servers, including creating and removing databases; mysqld: the actual MySQL server process;
Mysqldump: dump definitions and content of databases or tables to files; mysqlhotcopy: hot backup; mysqlimport: import data of different file formats to MySQL tables; mysqlshow: displays information about the server or any objects (databases and tables. Mysql_secure_installation: a script used to manage the root password, remotely access and remove temporary (test) databases, and temporary users. Generally, Root should be used only to log on to MySQL on the local database. we can add a user 'admin' with super management permissions to achieve remote maintenance. Tips: 1. log on as the root user. (enter mysql-u username-p password in the command line.) 2. run the following statement: mysql> grant all privilages on *. * to admin @ localhost identified by 'password' with grant option; mysql> grant all privilages on *. * to admin @ "%" identified by 'password' with grant option; "%" is a wildcard that allows admin users to initiate access from any host, password is the password set for the admin user. Mysql command line common command first, mysql service start and stop net stop mysqlnet start mysql second, login mysql syntax is as follows: mysql-u user name-p user password type command mysql-uroot-p, press enter and prompt you to enter the password, enter 12345, then press Enter to enter mysql, mysql prompt is: mysql> Note: If it is connected to another machine, you need to add a parameter-h machine IP. 3. add the new user format: grant permission on database. * to username @ login host identified by "password". for example, add a user user1 password password1 so that it can log on to the local machine, 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 user1 @ localhost Identified by "password1"; if you want this user to log on to mysql on any machine, change localhost to "% ".
If you do not want user1 to have a password, you can run another command to remove the password. Grant select, insert, update, delete on mydb. * to user1 @ localhost identified by ""; Step 4: log on to mysql by operating the database and run the following commands at the mysql prompt. each command ends with a semicolon. 1. display the database list. Show databases; by default, there are two databases: mysql and test. Mysql inventory contains the mysql system and user permission information. we change the password and add users, in fact, this database is actually operated. 2. display data tables in the database: use mysql; show tables; 3. display the data table structure: describe table name; 4. create and delete databases: create database name; drop database name; 5. create a table: use database name; create table name (field list); drop table name; 6. clear table records: delete from table name; 7. display table records: select * from table name; Step 5: export and import data 1. export data: mysqldump -- opt test> mysql. test exports the database test to mysql. test file, which is a text file such as mysqldump-u root-p123456 -- databases dbname> mysql. dbname is to export the database dbname to the mysql file. dbname.
2. import data: mysqlimport-u root-p123456 <mysql. dbname. No need to explain it. 3. import text data to the database: field data of text data is separated by the tab key. Use test; load data local infile "file name" into table name; 6. execute the external script file mysql-u test-p1234 -- database BugFree <D:/GreenAMP/BugFree. SQL
BitsCN.com

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.