MySQL commands in Linux

Source: Internet
Author: User

1. log on to MySQL-uroot-P.

 

2. MySQL cannot be accessed from the Internet in Linux

You have granted permissions in MySQL. It is still inaccessible on the Internet.

Problem:

CAT/etc/MySQL/My. conf

Find the following line

Bind-address = 127.0.0.1

For data security, MySQL is only waiting on 127.0.0.1 by default, and there is no comment in front, so it can only be accessed locally.

Solution:

Add a comment before bind-address to restart MySQL.

Step 2:

Mysql> use MySQL;

Mysql> Update user set host = '%' where user = 'root ';

Mysql> flush privileges;

Mysql> select 'host', 'user' from user where user = 'root ';

Use the following command to modify the settings! Restart MySQL

 

 

3.Database Export and Import

The following example shows how to export a MySQL database and often make a backup of data export. Putty logs on to the server and enters the directory of the database to be backed up. After the backup is complete, the database file will be saved in this directory. The operation steps on the command line are as follows:

(1 ).mysqldump -u username -p database_name > 20090708.sql
(2). Press ENTER
(3). Prompt to enter the password
(4) enter the password and press Enter.

Upload the MySQL database backup file (for example, the exported file 20090708. SQL) to your server, or directly download the database file to the new server through the wget command (mentioned above, run the following command:

(1 ).mysql -u username -p database_name < 20090708.sql
(2). Press ENTER
(3). Prompt to enter the password
(4) enter the password corresponding to the user name and press Enter.

Username, password, and database_name are the username, password, and Database Name of the MySQL database. The Bak. SQL file is the name of the backup file of the MySQL database. When importing data to a new server, the database name and user name must match the new one.

 

 

 

 

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.