Basic mysql operations in linux

Source: Internet
Author: User
Tags mysql commands


Java code
1. Create a management user for the mysqld Database: to set the root user as the administrator, run the following command;
[Root @ linuxsir01 root] # mysqladmin-u root password 123456
Generally, the directory where mysqladmin is located has been added to $ PATH. If this command is not found, check whether the software package is correctly installed. Make sure that both the Mysql-server and Mysql-client packages have been installed successfully, then you can run the rpm-qf Mysql-client Command to view the directory where the command is installed, add the directory to the $ PATH variable, or use the full PATH for -www.2cto.com. Note that the root here is not a system user, but a database user. You can also use another user name. 2. log on to the mysql database. Take the mysql database administrator root with the password 123456 as an example; [root @ linuxsir01root] #/opt/mysql/bin/mysql-u root-p if the command cannot be found, check the PATH variable and Enter password: Enter the password and press Enter. Then the following error occurs: Welcome to the MySQL monitor. commands end with; or \ g. your MySQL connection id is 9 Server version: 5.5.8 MySQL Community Server (GPL )........ Mysql> now the mysql management interface is displayed. Make sure that mysql is started before logon. 3. Operation Command: In the mysql database, each command is ended with a; sign. If you forget to add; Use \ c to exit. Show existing databases: mysql> show databases; + -------------------- + | Database | + -------------------- + | information_schema | crc | mysql | performance_schema | test | + ---------------- + 5 rows in set (0.01 sec) 4, create and delete databases: mysql> create database [database name]; for example, mysql> create database crc; delete a database: mysql> drop database [database name]; for example: mysql> drop database crc; 5. to operate a database, you must first specify a database as the current database. use the use command, Mysql> use [database name]; 6. Back up the database [root @ linuxsir01 root] # mysqldump-u root-p linux>/root/linux. SQL and Enter Password: first, backup the database as a database administrator (not a system administrator). Second, the backup destination is/root, and the backup file name is linux. SQL. In fact, the backup location and file name are determined based on your own situation. The file name can be obtained by yourself, or the path can be arranged by yourself. For example, if I want to back up the linux database to/home/beinan and the database file name is linuxsir031130. SQL, enter the following command. [Root @ linuxsir01 root] # mysqldump-u root-p linux>/home/beinan/linuxsir031130. SQL 7, import the backup database to the database. For example, if you want to back up linuxsir031130. SQL IN THE/home/beinan directory, import the database named linux as follows: [root @ linuxsir01 root] # mysql-u root-p linux

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.