MySQL command line has played a major role in using MySQL databases. The following describes five common MySQL command line usage for your reference.
1. [logon from different ports]
Choose Start> program> MySQL Command Line Client.
Enter password: ****** to log on to the MySQL service port.
Or
Run the command-> C: \ Program Files \ MySQL Server 5.2 \ bin>
Then use mysql to log on
C: \ Program Files \ MySQL Server 5.2 \ bin> mysql-uroot-h127.0.0.1-P3307-p
Enter password :******
You can also choose to log on to the remote MySQL
2. [execute an SQL file]
Create test database and data table
Mysql> source c:/test. SQL;
Content of the test. SQL file:
Create database if not exists testdb;
Use testdb;
Create table testtable
(TestName varchar (10 ));
3. [create a user]
Mysql> create user testuser identified by 'testpass ';
4. [grant permissions]
Mysql> grant all privileges on testdb. * to 'testuser' @ '% 'identified by 'testpass ';
5. [change the root password]
If you have logged on
1) use mysql
2) update user set password = password ('your password') where user = 'root ';
3) flush privileges;
If you do not log on, you want to enter the database without a password.
Turn off the service first
Then enter
Mysqld_safe -- skip-grant-tables &
Do not close this window. In this way, you do not need a password to enter the database. after entering the window, perform the "if you have logged on" step.
How to import SQL data through Mysql command lines
Mysql table index information
How to insert an array into a mysql table in php
MySQL Data Table Traversal method
Create a temporary table in php mysql