Ubuntu usage tips-MySQL

Source: Internet
Author: User
Tags mysql command line
MySQL is an open-source small-scale associated database management system. The developer is MySQLAB in Sweden. MySQL is widely used in small and medium websites on the Internet. Because of its small size, fast speed, and low total cost of ownership, especially the open source code, many small and medium websites have chosen MySQL as their website database to reduce their total cost of ownership. MySQL is a cross-platform database. The command for installing Server in Ubuntu is as follows: sudoapt-getinsta

MySQL is an open-source small-scale associated database management system. The developer is MySQL AB in Sweden. MySQL is widely used in small and medium websites on the Internet. Because of its small size, fast speed, and low total cost of ownership, especially the open source code, many small and medium websites have chosen MySQL as their website database to reduce their total cost of ownership.

MySQL is a cross-platform database. The command to install the Server in Ubuntu is as follows:

Sudo apt-get install mysql-server
The Client command is as follows:

Apt-get install mysql-client
By default, MySQL in Ubuntu only allows local access. If you want access from other machines, you need to change the/etc/mysql/my. cnf configuration file! Modify as follows:

$ Sudo gedit/etc/mysql/my. cnf
Earlier versions

> Modify skip-networking to # skip-networking
New Version

> Bind-address = 127.0.0.1 to bind-address = IP address of your machine
This allows other machines to access MySQL. If you want to know the path for storing mysql databases, you can use the following command

/Var/lib/mysql
Export and import data from mysql

Mysqldump Database Name> file name # Export Database
Mysqladmin create database name # create database
Mysql database name <file name # What should I do if I forget the mysql root Password When importing the database? You can use the following command to modify

Sudo/etc/init. d/mysql stop sudo mysqld_safe -- skip-grant-tables & sudo mysqladmin-u user password 'newpassword sudo mysqladmin flush-privileges modify the root password of mysql

Sudo mysqladmin-u root-p password 'your new password' if your mysql command line is displayed in Chinese? (Garbled) number, try the following command

Mysql> set names utf8;
Common mysql management statements

Show databases; # display all databases in mysql
Use xxx; # select the database name you need
Show tables; # display all tables in the selected Database
Show create table xxx; # display the SQL statement of the xxx table
Show table status; # query table status
Show full processlist; # query mysql Processes
Alter table site_stats engine = MyISAM; # convert a table to the MyISAM type and convert a table to a row lock.
Show variables; # view mysql variables
Automatic mysql backup

# Back up forum myweb database to the/backup/mysql directory and delete the backup records seven days ago
Mysqldump -- opt -- skip-lock-tables-u root forum | gzip-9>/backup/mysql/forum. 'date when policyuncm=d'. SQL .gz
Mysqldump -- opt -- skip-lock-tables-u root myweb | gzip-9>/backup/mysql/myweb. 'date when policyymm1_d'. SQL .gz
Find/backup/mysql/-type f-ctime + 7-exec rm {}\;

For more information about Ubuntu, see Ubuntu special page http://www.linuxidc.com/topicnews.aspx? Tid = 2

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.