Linux operation MySQL Database create library import, delete table

Source: Internet
Author: User
Tags mysql create mysql import

Ensure that the running database on the line is unavoidable I small white, because the company on-Line no way to the whole server, deep experience to the server big God domineering, so in order to increase memory, service the majority of staff friends record

Linux MySQL forgot root password cannot log in to MySQL

1, modify the MySQL configuration file/etc/my.conf under [mysqld] Add a line skip-grant-table;

2. After modifying the configuration file, restart the MySQL service mysqld Restart

3, then use the regular command to log on to MySQL mysql-u root-p When prompted to enter the password, just click on the return.

4, log in to MySQL after the execution of the statement to change the password update set Password=passeord (' root ') where user = ' root '; At this time passeord (' root ') root is the password of the newly-set root user

5. Take the first step, remove the skip-grant-table you added, then restart MySQL

First, Linux MySQL create, delete database

Use the command to enter MySQL

creat database name;

This creates a database of your own.

Use show databases to view all databases

Second, delete the database

Execute command drop databases database name;

Third, MySQL import, export database

Method One:

If you do not have a database, you need to establish a database through the Create tables table name; then use show databases; View database

If the database name exists using the use database, this command can be source/root/my.sql in the database; source/root/my.sql The command is to import a data file named My.sql into the database but /root/This is the path of the MySQL file stored on Linux, according to its own fill

Method Two:

/usr/local/mysql/bin/mysql-u root-p database name </root/test.sql;

/usr/local/mysql/bin/mysql-u root-p the database name to which database you want to import < The database file to import, such as command:/usr/local/mysql/bin/mysql-u root-p Daobidao </root/test.sql Import the database file Test.sql file into the Daobidao database; (but which database needs to be imported to)

Iv. MySQL export data and table structure of the database

Export Data and table structure of a database

/usr/local/mysql/bin/mysqldump -u root -p daobidao > /root/dbd.sql Enter password: /usr/local/mysql/bin/mysqldump-u root-p need to export the database > export the stored database file name; for example, command:/usr/local/mysql/bin/mysqldump-u root-p D Aobidao >/root/dbd.sql will export the Daobidao database and store it in the/root/dbd.sql file. Export the table structure of a database /usr/local/mysql/bin/mysqldump -u root -p -d daobidao > /root/dbd.sql Enter password: /usr/local/mysql/bin/mysqldump-u Root-p-D need to export the database > export the stored database file name; for example, command:/usr/local/mysql/bin/mysqldump-u root- p-d Daobidao >/root/dbd.sql will daobidao the database export table structure, stored in the/root/dbd.sql file. error ip:xxx.xxx.xxx.xx connection to remote MySQL server via local connection to remote database This is because I have a problem with the root authority of MySQL on my portal line, and I use it to modify root permissions by command . go to MySQL and then the root directory there is a MySQL below a user and then enter the user to perform the modified command update user set host= '% ' where user = ' root '; change root permissions to all to solve the problem /c1>

Linux operation MySQL Database create library import, delete table

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.