Five common MySQL command lines

Source: Internet
Author: User
Tags php mysql

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

Related Article

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.